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" ...
随机推荐
- GUI编程笔记(java)11:使用Netbeans工具进行GUI编程
Netbeans工具:是基于java语言进行GUI界面设计的工具 Visual Studio工具:是基于C#语言进行GUI界面设计的工具
- 【Android】广播BrocastReceiver
1.Android中广播主要分为两种:标准广播和有序广播. 标准广播:完全异步执行.广播发出后,所有的广播接收器几乎在同一刻收到广播事件,没有先后顺序之分. 优点:效率高 缺点:不能被截断 有序广播: ...
- Linux写配置HDF5的python包h5py
闲言碎语不讲,直接进入正题.Python在科学计算的应用越来越丰度,而hdf(5)数据的应用也非常广泛.python提供了h5py包供开发者处理数据(http://www.h5py.org/).在wi ...
- BFC与IFC
在我们做的网页上通常最重要的其中一点就是美观度,bfc他是一个块级格式化上下文,它是一个独立的渲染区域,只有Block-level box参与, 它规定了内部的Block-level Box如何布局, ...
- HTML5 canvas createRadialGradient()放射状/圆形渐变
定义和用法 createLinearGradient() 方法创建放射状/圆形渐变对象. 渐变可用于填充矩形.圆形.线条.文本等等. 提示:请使用该对象作为 strokeStyle 或 fillSty ...
- 转载[POJ题型分类]
北大ACM题分类 主流算法: 1.搜索 //回溯 2.DP(动态规划) 3.贪心 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同等安置矩形的 ...
- java 从jar包中读取资源文件
在代码中读取一些资源文件(比如图片,音乐,文本等等),在集成环境(Eclipse)中运行的时候没有问题.但当打包成一个可执行的jar包(将资源文件一并打包)以后,这些资源文件找不到,如下代码: Jav ...
- [转]Delphi中ShellExecute的妙用
Delphi中ShellExecute的妙用 ShellExecute的功能是运行一个外部程序(或者是打开一个已注册的文件.打开一个目录.打印一个文件等等),并对外部程序有一定的控制. ...
- (java)从零开始之--观察者设计模式Observer
观察者设计模式:时当一个对象发生指定的动作时,要通过另外的对象做出相应的处理. 步骤: 1. A对象发生指定的动作是,要通知B,C,D...对象做出相应的处理,这时候应该把B,C,D...对象针对A对 ...
- js编译和执行顺序
JS是一段一段执行的(以<script>标签来分割),执行每一段之前,都有一个“预编译”,预编译干的活是:声明所有var变量(初始为undefined),解析定义式函数语句. 还有个关于 ...