Test instructions: #转
/* Play a game where each round has one person scoring, or minus points, when all the wheels are finished, find the person with the highest score,
If it is more than one person, find out who is the first to reach the highest score or higher.
Save everyone's score first, and record the number of people who will win the prize and traverse all the rounds again.
Find the first person who is above the score and will win the prize.
*/
Sample Input
Input
3
Mike 3
Andrew 5
Mike 2
Output
Andrew
Input
3
Andrew 3
Andrew 2
Mike 5
Output
Andrew
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 6 struct Point7 {8 Charname[ -];9 intnum;Ten}a[ +],b[ +]; One Chars[ +][ *]; A intx[ +]; - - intMain () the { - intn,i,j; - while(~SCANF ("%d",&N)) - { + intD=0; -Memset (A,0,sizeof(a)); + for(i=0; i<n;i++) A { atscanf"%s%d",s[i],&x[i]); - if(d) - { - for(j=0; j<d;j++) - if(!strcmp (A[j].name,s[i])) - { ina[j].num+=X[i]; - Break; to } + if(j==d) - { the strcpy (A[d].name,s[i]); *a[d++].num=X[i]; $ }Panax Notoginseng } - Else the { +strcpy (a[0].name,s[i]); Aa[0].num=X[i]; thed++; + } - } $ intmaxn=0; $ for(i=0; i<d;i++) -maxn=Max (maxn,a[i].num); -memset (b,0,sizeof(b)); the intDd=0; - for(i=0; i<n;i++)Wuyi { the if(DD) - { Wu for(j=0; j<dd;j++) - if(!strcmp (B[j].name,s[i])) About { $b[j].num+=X[i]; - if(b[j].num>=maxn&&a[j].num==MAXN) - { -printf"%s\n", S[i]); A return 0; + } the Break; - } $ if(j==dd) the { the strcpy (B[dd].name,s[i]); theb[dd].num=X[i]; the if(b[dd].num>=maxn&&a[dd].num==MAXN) - { inprintf"%s\n", S[i]); the return 0; the } Aboutdd++; the } the } the Else + { -strcpy (b[0].name,s[i]); theb[0].num=X[i];Bayi if(x[i]>=maxn&&a[0].num==MAXN) the { theprintf"%s\n", S[i]); - return 0; - } thedd++; the } the } the } - return 0; the}
(Sunday race) Winner