标签:hdu1236
4 5 25 10 10 12 13 15 CS004 3 5 1 3 CS003 5 2 4 1 3 5 CS002 2 1 2 CS001 3 2 3 5 1 2 40 10 30 CS001 1 2 2 3 20 10 10 10 CS000000000000000001 0 CS000000000000000002 2 1 2 0
3 CS003 60 CS001 37 CS004 37 0 1 CS000000000000000002 20HintHuge input, scanf is recommended.
#include <stdio.h> #include <string.h> #include <algorithm> using std::sort; int prob[12]; struct Node{ char id[30]; int sco; } stu[1002]; bool cmp(Node a, Node b){ if(a.sco == b.sco) return strcmp(a.id, b.id) < 0; return a.sco > b.sco; } int main() { int n, m, k, tmp, mm, tmp2, id, i; while(scanf("%d%d%d", &n, &m, &k) == 3){ for(i = 1; i <= m; ++i) scanf("%d", &prob[i]); for(i = id = 0; i < n; ++i){ scanf("%s%d", stu[id].id, &mm); tmp = 0; while(mm--){ scanf("%d", &tmp2); tmp += prob[tmp2]; } if(tmp >= k) stu[id++].sco = tmp; } sort(stu, stu + id, cmp); printf("%d\n", id); for(i = 0; i < id; ++i) printf("%s %d\n", stu[i].id, stu[i].sco); } return 0; }
标签:hdu1236
原文地址:http://blog.csdn.net/chang_mu/article/details/38893921