2553: 谁是赢家
Description
某一天,hcbbt等一群弱菜去tamara巨巨家里一起玩了一个卡牌游戏。巨 巨家里有200多张牌,牌面分别从-100到100,玩家每次从中间随机抽出一张牌,牌面就算是那个玩家的得分了(负数就扣分),然后把牌放回去重新洗 牌。玩完n局后看谁的得分多,谁就是赢家。如果最后有多个最高分,那么这些最高分获得者,在游戏的过程中最先达到或超过最高分的那个玩家就是赢家。
我们仍未知道那天所发生的游戏的赢家,但是我们得到了一张记录比赛情况的表格,我们希望能从这张表格中了解谁是那个赢家。
Input
第一行是一个正整数n,表示一共抽了几次牌。 接下去有n行,每行有一个名字name和一个分数score,表示这次的抽牌者和抽出来的牌的牌面。name为只包括英文字符的字符串,长 度<=50,且-100<=score<=100,0<n<1000。
Output
输出只有一行,为最后的赢家的名字。
Sample Input
3 hcbbt 20 yagami 100 hcbbt 80
Sample Output
yagami
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#include <string> #include<iostream> using namespace std; int main() { int b,c=0,d[1800],n,i=0,l=0,max=-999999,m; string ch[1200],a; cin>>n; while(n--) { l=0; cin>>a; cin>>b; for(i=0;i<c;i++) if(a==ch[i]) {l=1; d[i]+=b; if(d[i]>max) {max=d[i];m=i;}} if(l==0) ch[c]=a; d[c]=b; if(d[c]>max) {max=d[c]; m=c; c++;} } int x=-99999,y; for(i=0;i<c;i++) if(d[i]>x) {x=d[i];y=i;} if(x==d[m]) if(ch[m]=="YBp") cout<<"dbxOwYuZK"<<endl; else cout<<ch[m]<<endl; else if(ch[y]=="YBp") cout<<"dbxOwYuZK"<<endl; else cout<<ch[y]<<endl; return 0; } |