模拟题
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
const int N = 10010, M = 100010;
int n, k, m;
int all[6];
char id[6];
int q, s;
struct stu {
int cnt;
char id[6];
int idNum;
bool st;
int qs[7] = {-1, -1, -1, -1, -1, -1, -1};
int sum;
bool operator<(const stu &obj) const {
if (sum != obj.sum) return sum > obj.sum;
if (cnt != obj.cnt) return cnt > obj.cnt;
return idNum < obj.idNum;
}
}stus[N];
// 获取整型的id
int getId(char s[]) {
int res = 0;
bool num = false;
for (int i = 0; i <= 4; i++) {
if (s[i] != '0') num = true;
if (num) res = res * 10 + s[i] - '0';
}
return res;
}
int main() {
scanf("%d%d%d", &n, &k, &m);
for (int i = 1; i <= k; i++) scanf("%d", &all[i]); // 读满分
while (m--) {
scanf("%s%d%d", id, &q, &s);
int i = getId(id);
if (s >= 0) stus[i].st = true;
stus[i].idNum = i;
for (int j = 0; j <= 4; j++) stus[i].id[j] = id[j];
if (stus[i].qs[q] != all[q] && s == all[q]) stus[i].cnt++; // 判断该题是否满分
if (s == -1 && stus[i].qs[q] == -1) stus[i].qs[q] = 0;
else stus[i].qs[q] = max(stus[i].qs[q], s);
}
for (int i = 1; i <= n; i++) { // 计算每个人的总分数
for (int j = 1; j <= k; j++) {
if (stus[i].qs[j] == -1) continue;
stus[i].sum += stus[i].qs[j];
}
}
sort(stus + 1, stus + 1 + n); // 排序
int x = 1, last = 0, t = 0; // 输出
for (int i = 1; i <= n; i++) {
if (!stus[i].st) continue;
t++;
if (i == 1) {
last = stus[i].sum;
} else {
if (stus[i].sum != last) {
last = stus[i].sum;
x = t;
}
}
printf("%d ", x);
printf("%s %d ", stus[i].id, stus[i].sum);
for (int j = 1; j <= k; j++) {
if (stus[i].qs[j] == -1) printf("- ");
else printf("%d ", stus[i].qs[j]);
}
puts("");
}
return 0;
}