使用结构体记录id,分数,考场排名,考场号
先分别对各考场进行排序,记录在该考场的排名;最后总的大排名。
//
// main.cpp
// PATA1025
//
// Created by Phoenix on 2018/2/7.
// Copyright © 2018年 Phoenix. All rights reserved.
//
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct Student {
char id[15];
int mark;
int loc;
int curRank;
}stu[30010];
bool cmp(Student a, Student b) {
if(a.mark != b.mark) return a.mark > b.mark;
else return strcmp(a.id, b.id) < 0;
}
int main(int argc, const char * argv[]) {
int n, num = 0;
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
int k;
scanf("%d", &k);
int begin = num;
for(int j = 0; j < k; j++) {
scanf("%s %d", stu[num].id, &stu[num].mark);
stu[num].loc = i;
num++;
}
sort(stu + begin, stu + num, cmp);
int rank = 1;