Kontringsattack
Time limit4sMemory limit1024 MB
Choose the smallest K so that counting matches with |F-S|<=K as ties maximizes Friberg's wins minus Skog's wins.
Problem
Friberg and Skog often play the computer game Kontringsattack together. In each match, a score is awarded that shows how well the player performed during the match. Sometimes Skog claims he is better than Friberg at Kontringsattack, because he scored more points than Friberg in a number of matches. Friberg counters by claiming that if the difference between Friberg's and Skog's scores in a match is less than or equal to some number , then it is impossible to determine who was better in that match. More formally: if Friberg scored points and Skog scored points, then they are considered equally good when , otherwise the player with the higher score is better.
Of course, it is Friberg who decides the number . Given a number of matches and Friberg's and Skog's scores in them, what value should Friberg set for so that the difference between the number of matches where Friberg is better and the number of matches where Skog is better becomes as large as possible? If there are several such values, find the smallest one.
Input
- The first line contains an integer ().
- The following lines contain two integers , (), Friberg's score and Skog's score respectively.
Output
One line with the integer .