#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;struct User{ int id; int pScore[6]; int totalScore; bool valid; int perfectPRoblem; int rank;}user[10010];User temp[10010];bool cmp(User a, User b){ if (a.totalScore != b.totalScore) return a.totalScore > b.totalScore; else if (a.perfectProblem != b.perfectProblem) return a.perfectProblem > b.perfectProblem; else return a.id < b.id; }void initial(){ for (int i = 0; i < 10010; i++){ for (int j = 1; j < 6; j++) user[i].pScore[j] = -2; user[i].totalScore = 0; user[i].valid = false; user[i].perfectProblem = 0; }}int main(){ int n, k, m; scanf("%d%d%d", &n, &k, &m); initial(); int p[6]; for (int i = 1; i <= k; i++) scanf("%d", &p[i]); for (int i = 0; i < m; i++){ int useId,proId,patScore; scanf("%d%d%d", &useId,&proId,&patScore); user[useId].id = useId; if(user[useId].pScore[proId] < patScore) user[useId].pScore[proId] = patScore; if (patScore != -1) user[useId].valid = true; } int j = 0; for (int i = 0; i < 10010; i++){ if (user[i].valid){ for (int x = 1; x <= k; x++){ if (user[i].pScore[x] != -2 && user[i].pScore[x] != -1) user[i].totalScore += user[i].pScore[x]; if (user[i].pScore[x] == p[x]) user[i].perfectProblem++; } temp[j++] = user[i]; } } sort(temp, temp + j, cmp); int Rank = 1; for (int i = 0; i < j; i++){ if (i == 0 || temp[i].totalScore < temp[i - 1].totalScore) temp[i].rank = Rank; else temp[i].rank = temp[i - 1].rank; Rank++; printf("%d %05d %d", temp[i].rank, temp[i].id, temp[i].totalScore); for (int x = 1; x <= k; x++){ if (temp[i].pScore[x] == -1) printf(" 0"); else if (temp[i].pScore[x] == -2) printf(" -"); else printf(" %d", temp[i].pScore[x]); } printf("/n"); } return 0;}
新闻热点
疑难解答