[PAT甲级]1025 PAT Ranking
以下所述均为个人理解,如有错误,还望指正
题目
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 NNN (≤100\le 100≤100), the number of test locations. Then NNN ranklists follow, each starts with a line containing a positive integer KKK (≤300\le 300≤300), the number of testees, and then KKK 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:
registration_number final_rank location_number local_rank
The locations are numbered from 1 to NNN. 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.
##题解1:(初次完成)
本题仅使用简单的排序即可,注意分组排序和全部排序下标的不同
#include <bits/stdc++.h>
using namespace std;
struct Student
{
string numbers;
int score;
int local_rank;
int final_rank;
int location;
} Students[30010];
bool cmp(Student stu1, Student stu2)
{
return stu1.score == stu2.score ? stu1.numbers < stu2.numbers : stu1.score > stu2.score;
}
int main()
{
int N, K, NUM = 0;
cin >> N;
for (