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" ...
随机推荐
- Java中获得程序当前路径的4中方法
Java中获得程序当前路径的4中方法: 在Application中: import java.util.*; public class TestUserDir { public static void ...
- Android(java)学习笔记199:Android中补间动画(Tween Animation)
本文主要简单介绍补间动画使用代码实现, 关于使用xml实现补间动画,可以参看:自定义控件三部曲之动画篇(一)——alpha.scale.translate.rotate.set的xml属性及用法 1. ...
- label_设置行距、字距及计算含有行间距的label高度
// // ViewController.m // CNBlogs // // Created by PXJ on 16/5/27. // Copyright © 2016年 PXJ. All ...
- kissy
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
- [o] duplicate column name: _id 问题解决
Android下使用SQLite数据库,报错:duplicate column name: _id 数据库文件下有两列数据的名称一样,原因是定义数据类型时有重复,如,我的定义: //复制上一行增加TY ...
- Member var and Static var.
/* member variable and static variable: 1,invoke ways: member variable,also called 'instance' variab ...
- JavaScript学习笔记--ES6学习(五) 数值的扩展
ES6 对于数值类型 (Number) 进行了一下扩展: 1.对于二进制和八进制提供了新的写法 ES6对于二进制和八进制的数值提供了新的写法,分别用0b (或者0B) 和0o (或者0o) 表示.例如 ...
- java把InputStram 转换为String
public static String readStream(InputStream in) throws Exception{ //定义一个内存输出流 ByteArrayOutputStream ...
- extend简单用法
eg:var obj1=[{a:1,b:2},{a:2,b:3}] var obj2=[{c:3,d:2},{c:4,d:3}] var resultArray=[]; for (var i = 0; ...
- Ubuntu 12.04 下安装配置 JDK 7(tar)
第一步:下载jdk-7u45-linux-i586.tar.gz 到Orcale的JDK官网下载JDK7的tar包 第二步:解压安装 tar -zxvf ./jdk-7u45-linux-i586.t ...