codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

174A.md (2259B)


      1 Source: https://codeforces.com/contest/174/problem/A
      2 
      3 A. Problem About Equation
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 A group of *n* merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the *n* mugs must be the same.
     22 
     23 Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has *a*1 milliliters of the drink, the second one has *a*2 milliliters and so on. The bottle has *b* milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.
     24 
     25 Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously:
     26 
     27 * there were *b* milliliters poured in total. That is, the bottle need to be emptied;
     28 * after the process is over, the volumes of the drink in the mugs should be equal.
     29 
     30 Input
     31 
     32 The first line contains a pair of integers *n*, *b* (2 ≤ *n* ≤ 100, 1 ≤ *b* ≤ 100), where *n* is the total number of friends in the group and *b* is the current volume of drink in the bottle. The second line contains a sequence of integers *a*1, *a*2, ..., *a**n* (0 ≤ *a**i* ≤ 100), where *a**i* is the current volume of drink in the *i*-th mug.
     33 
     34 Output
     35 
     36 Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print *n* float numbers *c*1, *c*2, ..., *c**n*, where *c**i* is the volume of the drink to add in the *i*-th mug. Print the numbers with no less than 6 digits after the decimal point, print each *c**i* on a single line. Polycarpus proved that if a solution exists then it is unique.
     37 
     38 Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma.
     39 
     40 Examples
     41 
     42 Input
     43 
     44 ```
     45 5 50  
     46 1 2 3 4 5
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 12.000000  
     53 11.000000  
     54 10.000000  
     55 9.000000  
     56 8.000000
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 2 2  
     63 1 100
     64 ```
     65 
     66 Output
     67 
     68 ```
     69 -1
     70 ```