CodeForce 2A Winner
很多人玩一个游戏,每一轮有一个人得分或者扣分,最后分数最高的人夺冠;如果最后有多个人分数都是最高的,则这些人里面,在比赛过程中首先达到或者超过这个分数的人夺冠。现在给定最多1000轮每轮的情况,求最后的冠军是谁。
========================================================================================
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long LL;
const LL INF = 0xffffff;
const int maxn = ;
const LL MOD = 1e9+;
struct node
{
char name[maxn];
int coun;
int sorce;
} P[maxn], ans, Read[maxn];
/// int main()
{
int n, k = , i, j, Max = -INF;
memset(P, , sizeof(P));
ans.sorce = -INF;
cin >> n; for(i=; i<n; i++)
{
cin >> Read[i].name >> Read[i].sorce; for(j=; j<k; j++)
{
if(strcmp(P[j].name, Read[i].name) == )
{
P[j].sorce += Read[i].sorce;
break;
}
} if(j == k)
{
strcpy(P[j].name,Read[i].name);
P[k++].sorce = Read[i].sorce;
}
} for(i=; i<k; i++)
Max = max(P[i].sorce, Max);
k = ;
memset(P, , sizeof(P)); for(i=; i<n; i++)
{
for(j=; j<k; j++)
{
if(strcmp(P[j].name, Read[i].name) == )
{
P[j].sorce += Read[i].sorce;
if(P[j].sorce >= Max && P[j].coun == -)
P[j].coun = i;
break;
}
} if(j == k)
{
strcpy(P[j].name,Read[i].name);
P[k++].sorce = Read[i].sorce;
P[j].coun = -;
if(P[j].sorce >= Max)
P[j].coun = i;
}
} for(i=; i<k; i++)
{
if(ans.sorce < P[i].sorce || (ans.sorce == P[i].sorce && P[i].coun < ans.coun) )
ans = P[i];
} cout << ans.name << endl;
return ;
}
CodeForce 2A Winner的更多相关文章
- CodeForces 2A Winner
Winner Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- codeforces 2A Winner (好好学习英语)
Winner 题目链接:http://codeforces.com/contest/2/problem/A ——每天在线,欢迎留言谈论. 题目大意: 最后结果的最高分 maxscore.在最后分数都为 ...
- CodeForces 2A - Winner(模拟)
题目链接:http://codeforces.com/problemset/problem/2/A A. Winner time limit per test 1 second memory limi ...
- Codeforces 2A :winner
A. Winner time limit per test 1 second memory limit per test 64 megabytes input standard input outpu ...
- 红米2A高配刷机记录
2014816 机型:红米2A高配版 设备型号:2014816 CPU:高通 线刷:fastboot平台 http://192.168.7.118/MesReports/Reports/Cutting ...
- HDU 5754 Life Winner Bo 组合博弈
Life Winner Bo Problem Description Bo is a "Life Winner".He likes playing chessboard gam ...
- HDU 2509 Be the Winner nim博弈变形
Be the Winner Problem Description Let's consider m apples divided into n groups. Each group contai ...
- mac上执行sed的编辑 -i命令报错sed: 1: "test.txt": undefined label ‘est.txt’或sed: 1: "2a\test\": extra characters after \ at the end of a command
问题一 sed编辑命令:[sed -i 's/a/b/g' test.txt] 报错:sed: 1: "test.txt": undefined label 'est.txt' ...
- HDU5754 Life Winner Bo(博弈)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life Winner" ...
随机推荐
- js中offsetHeight、clientHeight、scrollHeight等相关属性区分总结
今天再次遇到了offset***.client***.scroll***的这三类属性的问题,总是混淆,现归纳总结如下: 大体上来说可以这样理解: client***属性(clientWidth.cli ...
- 关于promise
后来发现promise是解决异步的一个链式调用的好的方法,避免了所谓的回调的监狱, 它有三个状态,未作为,已经完成和已经失败,起始是未作为,然后有了动作总会有个结果, 分成resolve,已经顺利ok ...
- HTML 5 Audio/Video DOM buffered 属性
1.实例1获取视频第一段缓冲范围部分,以秒计: myVid=document.getElementById("video1"); alert("Start: " ...
- myEclipse修改deploy location
- .net开发windows服务
最近一个月都异常的繁忙,项目进度非常的紧,回头看看自己的blog,整整一个5月都没有一篇文章,非常惭愧,现在补几篇文章,介绍一下我最近关注的技术.这篇文章将介绍Windows服务程序的开发.摘要:本文 ...
- (whh仅供自己参考)进行ip网络请求的步骤
这个过程大致是这个样子: 1 添加通知 2 发送网络请求 里边有一个发送通知的操作 3 执行发送通知的具体操作 代码如下: 1 在VC添加通知 [[NSNotificationCenter defau ...
- SGU 114.Telecasting station
题意: 百慕大的每一座城市都坐落在一维直线上.这个国家的政府决定建造一个新的广播电视台.经过了许多次试验后,百慕大的科学家们提出了一个结论,在每座城市的不满意度等于这座城市的市民数与这座城市与广播电视 ...
- Visual Studio 2013环境下操作vc6/vc7/vc8等低版本平台项目【编译|生成|调试】
现代化的开发环境,微软一直在推出更新换代,我们所处的技术环境在日新月异的变化:不过在中国多数人们一边疲惫的追赶着时代的步伐,一边坚守着自己所获悉所掌握的那些紧吧吧的知本.对技术工具的掌握并非他们所想要 ...
- java的动态绑定与双分派(规避instanceof)
1. 动态绑定的概念 指程执行期间(而不是在编译期间)判断所引用对象的实际类型,根据其实际的类型调用其相应的方法 . 例如: package org.demo.clone.demo; public c ...
- 关于Linux 交互(用户操作接口)
Linux 系统提供两种基本接口给用户操作:命令行,图形界面. 不同接口也有相应的访问终端. 一.命令行 Command Line Linux系统命令行,一般指 Shell. Shell 接受经键盘输 ...