Melita has just returned from the annual pig slaughter. Don't worry, this is a regular thing in Croatia. The best part was the abundance of food! There was everything, starting from good spicy sausages, ham, black pudding, up to teewurst, top quality bacon and čvarci, all with warm white bread and butter. After these appetizers, it was the perfect time to whip up a deep pot full of sarma (Melita ate twentyish of them) as well as a large platter of fine roast pork, so soft that it almost melts in your mouth. They watered all of this down with copious gulps of the best dry white wine that made them even hungrier.
Butcher Bajs kept his award-winning ham for the very end.
At the end of the slaughter, the Man of the Year will be declared. A ranking list is made according to the total kilos of meat eaten. Bajs impacts directly on this list by choosing the amount of ham to distribute. Although Bajs has been offered bribes many times, he refused each time, saying that he was an honest man who would not hurt a fly.
Bajs cares about order, because he's a nice gentleman, and wants to have the order of people in the exact form of
Input Specification
The first line of input contains an integer
Each of the following
Output Specification
The first and only line of output must contain -1
if the required order cannot be achieved. Otherwise, output the required amount of ham in kilos, a real number (rounded up to
Sample Input 1
3
7 1
3 2
10 0
Sample Output 1
10.5
Explanation for Sample Output 1
Sample Input 2
3
2 1
4 0
0 3
Sample Output 2
-1
Sample Input 3
5
15 4
6 7
12 5
9 6
1 7
Sample Output 3
87
Comments
If your submission gets WA here but ACs on evaluator.hsin.hr, please report an issue and link your pertinent submission so the DMOJ staff can take a closer look. Do not hard-code the cases you fail on just to get AC.
(The technical reason for this is that we can prove that there are test cases where correct answers take more than 12 decimal places to express properly, and we do not know how the output validator is implemented officially. Consequently, there may be disparities between the two sites that need to be manually resolved.)