标签:
http://acm.hdu.edu.cn/showproblem.php?pid=1236
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 <cstdio> #include <algorithm> #include <string> #include <iostream> using namespace std; typedef pair<int ,string >Q; int main() { //freopen("F://in.txt","r",stdin); int n,m,g; while(scanf("%d",&n)!=EOF&&n){ Q mem[1010]; int score[11],x,y,ans=0; string s; scanf("%d%d",&m,&g); for(int i=1;i<=m;i++)scanf("%d",&score[i]); for(int i=0;i<n;i++){ cin>>s; scanf("%d",&x); int sum=0; while(x--){ scanf("%d",&y); sum+=score[y]; } if(sum>=g)ans++; sum=-sum; mem[i]=make_pair(sum,s); } sort(mem,mem+n,less<Q>()); printf("%d\n",ans); for(int i=0;i<n;i++) { if(mem[i].first>-g)break; cout<<mem[i].second; printf(" %d\n",-mem[i].first); } } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/burning_newbie/article/details/47746993