排名(水题)
排名
Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19177????Accepted Submission(s): 7033
?
Input 測試輸入包含若干場考試的信息。每場考試信息的第1行給出考生人數N ( 0 < N? < 1000 )、考題數M ( 0 < M < = 10 )、分數線(正整數)G;第2行排序給出第1題至第M題的正整數分值;以下N行,每行給出一? 名考生的準考證號(長度不超過20的字符串)、該生解決的題目總數m、以及這m道題的題號? (題目號由1到M)。? 當讀入的考生人數為0時,輸入結束,該場考試不予處理。??
Output 對每場考試,首先在第1行輸出不低于分數線的考生人數n,隨后n行按分數從高? 到低輸出上線考生的考號與分數,其間用1空格分隔。若有多名考生分數相同,則按他們考? 號的升序輸出。??
Sample Input 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?
Sample Output 3 CS003 60 CS001 37 CS004 37 0 1 CS000000000000000002 20 Hint Huge input, scanf is recommended.題解:水題;
代碼:
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<stack> #include<vector> #include<map> #include<string> using namespace std; const int INF=0x3f3f3f3f; const double PI=acos(-1.0); #define mem(x,y) memset(x,y,sizeof(x)) #define SI(x) scanf("%d",&x) #define SL(x) scanf("%lld",&x) #define PI(x) printf("%d",x) #define PL(x) printf("%lld",x) #define P_ printf(" ") #define T_T while(T--) typedef long long LL; int score[15]; int ans; int G; struct Node{char s[25];int len;int m[15];int tot;Node init(){tot=0;int len;scanf("%s",s);scanf("%d",&len);for(int i=0;i<len;i++)scanf("%d",&m[i]),tot+=score[m[i]];if(tot>=G)ans++;}friend int operator < (Node a,Node b){if(a.tot!=b.tot)return a.tot>b.tot;else return strcmp(a.s,b.s)<0;} }; Node m[1010]; int main(){int N,M,len;while(SI(N),N){SI(M);SI(G);for(int i=1;i<=M;i++)SI(score[i]);ans=0;for(int i=0;i<N;i++){m[i].init();}sort(m,m+N);printf("%d\n",ans);for(int i=0;i<N;i++){if(m[i].tot>=G)printf("%s %d\n",m[i].s,m[i].tot);else break;}}return 0; }
?
轉載于:https://www.cnblogs.com/handsomecui/p/5087042.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
- 上一篇: 第二个spring冲刺总结
- 下一篇: 11月25号站立会议