codeforces-scrape

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

99B.md (2580B)


      1 Source: https://codeforces.com/problemset/problem/99/B
      2 
      3 B. Help Chef Gerasim
      4 
      5 time limit per test
      6 
      7 0.5 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
     22 
     23 To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
     24 
     25 Input
     26 
     27 The first line contains integer *n* — the number of cups on the royal table (1 ≤ *n* ≤ 1000). Next *n* lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
     28 
     29 Output
     30 
     31 If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "*v* ml. from cup #*a* to cup #*b*." (without the quotes), where *v* represents the volume of poured juice, *a* represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), *b* represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 5  
     39 270  
     40 250  
     41 250  
     42 230  
     43 250
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 20 ml. from cup #4 to cup #1.
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 5  
     56 250  
     57 250  
     58 250  
     59 250  
     60 250
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 Exemplary pages.
     67 ```
     68 
     69 Input
     70 
     71 ```
     72 5  
     73 270  
     74 250  
     75 249  
     76 230  
     77 250
     78 ```
     79 
     80 Output
     81 
     82 ```
     83 Unrecoverable configuration.
     84 ```