PAT 甲级 1025
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now it is your job to write a program to correctly merge all the ranklists and generate the final rank.
Input Specification:
Each input file contains one test case. For each case, the first line contains a positive number N (≤100), the number of test locations. Then N ranklists follow, each starts with a line containing a positive integer K (≤300), the number of testees, and then K lines containing the registration number (a 13-digit number) and the total score of each testee. All the numbers in a line are separated by a space.
Output Specification:
For each test case, first print in one line the total number of testees. Then print the final ranklist in the following format:
1 | registration_number final_rank location_number local_rank |
The locations are numbered from 1 to N. The output must be sorted in nondecreasing order of the final ranks. The testees with the same score must have the same rank, and the output must be sorted in nondecreasing order of their registration numbers.
Sample Input:
1 | 2 |
Sample Output:
1 | 9 |
题目大意
给所有地区的考生排名。题目首先给出N,表示有N个地区,之后每个地区给出K,及K个考生的考号,分数,最后要求你不仅要输出每个考生的总排名,还要输出每个考生的地区排名
思路
首先建立一个结构体,存储考生的考号,分数,地区序号及地区排名,然后建立一个充分大(>=30000)的结构体数组,然后依次每输入一个地区的考生信息,就对该地区的考试进行排序,同时计算其地区排名。输入完毕后,对该结构体数组进行总排序,最终计算总排名并输出
1 |
|