Pro.ID22694 TitleMax's kingdom Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22694 AC0 Submit0 Ratio- 时间&空间限制描述Max is the king of the universe, he rules billions of planets. In each planet, there may be several residents. Residents of Max's kingdom will never die, so some of them may be as old as the universe (It is a magic world, isn't it? ). One day, Max wants to know how intellegent his people are so that he collects the intellegence information of all residents throughout universe. The intellegence can be presented by integer under a standard decided by Max. (That means, if the intellegence of resident Bob is presented as 10000, Bob is much more intellgent than the stadard. And if Max's intellegence number is 0, Max is as intellegent as the standard.) Actually, Max just cares how intellegent each planet is. To decide the intellegent degree of one planet, Max will take the middle one from all intellegent numbers of that planet and make it as the criteria. Here is the method to pick up the middle one: Supposed there are n residents in planet i. The intellegence of them are a1, a2, ..., an ( a1 ≤ a2 ≤ a3 ... ≤ an ). If n is odd, then the middle one is a[(n+1)/2], otherwise, middle one equals (a[n/2] + a[n/2 + 1]) / 2 (Here character / means integer division, e.g. 3/2 = 1, 4/2 = 2). Since there are too many residents to process, now is your task to tell Max how smart his people are. 输入Input contains multiple test data sets. For each data set, there is one integer, n ( 1 ≤ n ≤ 1 000 000 ) the number of residents, in first line. Then comes n lines, each line i has two integers: p, a ( 1 ≤ p < 1.5*109, |a| ≤ 1.5*109 ) which means that resident i comes from planet p and his/her intellegent number is a. Input is terminated by EOF. 输出Description Max is the king of the universe, he rules billions of planets. In each planet, there may be several residents. Residents of Max's kingdom will never die, so some of them may be as old as the universe (It is a magic world, isn't it? ). One day, Max wants to know how intellegent his people are so that he collects the intellegence information of all residents throughout universe. The intellegence can be presented by integer under a standard decided by Max. (That means, if the intellegence of resident Bob is presented as 10000, Bob is much more intellgent than the stadard. And if Max's intellegence number is 0, Max is as intellegent as the standard.) Actually, Max just cares how intellegent each planet is. To decide the intellegent degree of one planet, Max will take the middle one from all intellegent numbers of that planet and make it as the criteria. Here is the method to pick up the middle one: Supposed there are n residents in planet i. The intellegence of them are a1, a2, ..., an ( a1 ≤ a2 ≤ a3 ... ≤ an ). If n is odd, then the middle one is a[(n+1)/2], otherwise, middle one equals (a[n/2] + a[n/2 + 1]) / 2 (Here character / means integer division, e.g. 3/2 = 1, 4/2 = 2). Since there are too many residents to process, now is your task to tell Max how smart his people are. Input Input contains multiple test data sets. For each data set, there is one integer, n ( 1 ≤ n ≤ 1 000 000 ) the number of residents, in first line. Then comes n lines, each line i has two integers: p, a ( 1 ≤ p < 1.5*109, |a| ≤ 1.5*109 ) which means that resident i comes from planet p and his/her intellegent number is a. Input is terminated by EOF. Output For each test data set, one output data set should be generated as follow: For each planet p appears in the test data set, output one line presenting two integers: p which is the planet identifier from input and the middle one number described as above. Output data set should be sorted by planet identifier in ascending order. Sample Input 3 Sample Output 1 5 Source 样例输入3 样例输出1 5 作者 |