(周日赛)Winner

题意:#转

/*玩一个游戏,每轮有一个人得分,或减分,当所有轮完成后,找出分数最高的那个人,
如果是多个人,找出那些人中第一个达到最高分或更高的人。

先保存好每个人的分数,记录下究竟有那几个人会得奖,再次遍历所有回合,
找出第一个高于等于那个分数的且最终会得奖的人。
*/

Sample Input

Input

3mike 3andrew 5mike 2

Output

andrew

Input

3andrew 3andrew 2mike 5

Output

andrew
 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<algorithm>
 4 using namespace std;
 5
 6 struct point
 7 {
 8     char name[20];
 9     int num;
10 }a[1000],b[1000];
11 char s[1000][35];
12 int x[1000];
13
14 int main()
15 {
16     int n,i,j;
17     while(~scanf("%d",&n))
18     {
19         int d=0;
20         memset(a,0,sizeof(a));
21         for(i=0;i<n;i++)
22         {
23             scanf("%s %d",s[i],&x[i]);
24             if(d)
25             {
26                 for(j=0;j<d;j++)
27                     if(!strcmp(a[j].name,s[i]))
28                     {
29                         a[j].num+=x[i];
30                         break;
31                     }
32                 if(j==d)
33                 {
34                     strcpy(a[d].name,s[i]);
35                     a[d++].num=x[i];
36                 }
37             }
38             else
39             {
40                 strcpy(a[0].name,s[i]);
41                 a[0].num=x[i];
42                 d++;
43             }
44         }
45         int maxn=0;
46         for(i=0;i<d;i++)
47             maxn=max(maxn,a[i].num);
48         memset(b,0,sizeof(b));
49         int dd=0;
50         for(i=0;i<n;i++)
51         {
52             if(dd)
53             {
54                 for(j=0;j<dd;j++)
55                     if(!strcmp(b[j].name,s[i]))
56                     {
57                         b[j].num+=x[i];
58                         if(b[j].num>=maxn&&a[j].num==maxn)
59                         {
60                             printf("%s\n",s[i]);
61                             return 0;
62                         }
63                         break;
64                     }
65                     if(j==dd)
66                     {
67                         strcpy(b[dd].name,s[i]);
68                         b[dd].num=x[i];
69                         if(b[dd].num>=maxn&&a[dd].num==maxn)
70                         {
71                             printf("%s\n",s[i]);
72                             return 0;
73                         }
74                         dd++;
75                     }
76             }
77             else
78             {
79                 strcpy(b[0].name,s[i]);
80                 b[0].num=x[i];
81                 if(x[i]>=maxn&&a[0].num==maxn)
82                 {
83                     printf("%s\n",s[i]);
84                     return 0;
85                 }
86                 dd++;
87             }
88         }
89     }
90     return 0;
91 }
时间: 2024-08-05 15:55:01

(周日赛)Winner的相关文章

(周日赛)Friends or Enemies?

题意:判断两点是否在线段的同一方,点不能在线上. 题解:模拟一下 DescriptionA determined army on a certain border decided to enumerate the coordinates in its patrol in a way to make it difficult for the enemy to know what positions they are referring to in the case that the radio s

(周日赛)Sort the Array

题意:一段数字,逆置其中两个使其递增 DescriptionBeing a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of ndistinct integers. Unfortunately, the size of a is too small. You want a bigger array! Your friends agre

赛门铁克23亿美元打造全球最大数字安全平台

作者:茱莉叶 [IT战略家] 赛门铁克打造全球最大数字安全平台   赛门铁克周日同意以23亿美元收购消费者身份防窃取保护服务商LifeLock,打造"全球最大的消费者和家庭数字安全平台",扩展赛门铁克的消费者系列产品. 赛门铁克采用现金和7.5亿美元新债务的形式,以每股24美元,高于LifeLock上周五收盘价16%的价格进行收购.截至上周五,LifeLock股价在2016年上涨了45%,市值达到约19.5亿美元.该交易预计将于2017年第一个季度完成.赛门铁克的董事会也将公司的股票回

hdu5512 Pagodas(2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学) )

Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 14 Accepted Submission(s): 13 Problem Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai M

2015年ACM长春区域赛比赛感悟

距离长春区域赛结束已经4天了,是时候整理一下这次比赛的点点滴滴了. 也是在比赛前一周才得到通知要我参加长春区域赛,当时也是既兴奋又感到有很大的压力,毕竟我的第一场比赛就是区域赛水平,还是很有挑战性的.在接到通知后,我便开始临阵抱佛脚,课也不怎么听了,上课把时间全都用在了看各种算法上,回到实验室便整理模板.开cf练手.在去比赛前,已经将所看过的算法模板都整理好了. 周五上午9点三刻左右,我们便出发了,需要经历12个小时才能到达我们此次的目的地——长春,途中我还将计算几何稍微看了一下.直到晚上11点

第39届ACM亚洲区域赛牡丹江赛区赛后总结

2014年10月10日,周五,早晨匆匆忙忙的出了寝室,直奔复印社去打了两份模板,然后直接就去上课了.第三节课下课,直接跟老师讲了一声,就去实验室跟学长们汇合了.12点半,踏上了开往牡丹江的列车,我们那节车厢俨然成了参赛队伍的专列了,背后坐的是吉大的,学生还没咋看,主要都看他们教练了,那肚子挺得,那得多腐败啊...旁边的是华南理工的,没想到旁边的那个妹纸,竟然是他们的教练!!!看着就是学生呀,竟然已经留校当教练了,唉,好可惜(你们懂得,嘿嘿~~~) 抵达牡丹江,这是我第二次踏上这块土地,当时想着这

[ACM]辽宁省赛2010 (HZNU 1081-1089)

虽然退役了,但偶尔水几题醒醒脑还是不错的=_= 1085 Intermediary 暂时还没做 1081: Dinner 时间限制: 1 Sec  内存限制: 32 MB提交: 5  解决: 3[提交][状态][讨论版] [Edit] [TestData] 题目描述 Little A is one member of ACM team. He had just won the gold in World Final. To celebrate, he decided to invite all

acm集训训练赛A题【签到题】

一.题目 Description After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of nhorizontal and m vertical sticks. An intersection point is any point on the grid which is formed by t

ACdream群赛1112(Alice and Bob)

题意:http://acdream.info/problem?pid=1112 Problem Description Here  is Alice and Bob again ! Alice and Bob are playing a game. There are several numbers.First, Alice choose a number n.Then he can replace n (n > 1)with one of its positive factor but not