Codeforces 2 A. Winner
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈。。。。。。。
先让我笑完。。。。。。。。。。。。。。。。
就是一道撒比题啊,一开始是题目看错= =、是,但是后面还是自己不仔细错的。。。。。不存在题目坑这种情况。。。。。。。
不想写题意了,我想吐啊这题。。。没用map。。
就是n个操作好,然后求出一个最大值,然后满足这些最大值里面找一个最先的。。。。。。真的是撒比模拟,,,wa了那么久A掉也不怎么开心,自己好菜
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
#define LL long long
const double pi = acos(-1.0);
#define Len 200005
#define mod 19999997
const int INF = 0x3f3f3f3f;
#define exp 1e-6
struct asd{
char ss[1010];
int num;
};
asd q[1010];
asd qq[1010];
asd p[1010];
char s1[1010][1010];
char tep[1010];
int sum;
int JUDGE(int x)
{
char ss[1010];
strcpy(ss,p[x].ss);
for(int i=0;i<sum;i++)
{
if(strcmp(ss,s1[i])==0)
return 1;
}
return 0;
}
void debug()
{
for(int i=0;i<sum;i++)
printf("%s\n",s1[i]);
}
int main()
{
int n;
int k,num,flag;
cin>>n;
int Tmax;
Tmax=0;
num=0;
for(int i=0;i<n;i++)
{
scanf("%s%d",&tep,&k);
strcpy(qq[i].ss,tep);
qq[i].num=k;
flag=0;
for(int j=0;j<num;j++)
{
if(strcmp(q[j].ss,tep)==0)
{
flag=1;
q[j].num+=k;
}
}
if(!flag)
{
strcpy(q[num].ss,tep);
q[num].num+=k;
num++;
}
}
Tmax=0;
for(int i=0;i<n;i++)
{
if(Tmax<q[i].num)
{
Tmax=q[i].num;
}
}
//printf("%d\n",Tmax);
sum=0;
for(int i=0;i<num;i++)
{
if(q[i].num==Tmax)
{
strcpy(s1[sum++],q[i].ss);
}
}
//debug();
num=0;
for(int i=0;i<n;i++)
{
strcpy(tep,qq[i].ss);
k=qq[i].num;
flag=0;
for(int j=0;j<num;j++)
{
if(strcmp(tep,p[j].ss)==0)
{
p[j].num+=k;
if(p[j].num>=Tmax&&JUDGE(j))
{
printf("%s",p[j].ss);
return 0;
}
flag=1;
}
}
if(!flag)
{
strcpy(p[num].ss,tep);
p[num].num=k;
if(p[num].num>=Tmax&&JUDGE(num))
{
printf("%s",p[num].ss);
return 0;
}
num++;
}
}
return 0;
}
/*
6
andrew 3
andrew 2
andrew 2
andrew 3
mike 5
mike 5
*/
Codeforces 2 A. Winner的更多相关文章
- Codeforces 2A :winner
A. Winner time limit per test 1 second memory limit per test 64 megabytes input standard input outpu ...
- 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
Winner Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- Codeforces Beta Round #2 A. Winner 水题
A. Winner 题目连接: http://www.codeforces.com/contest/2/problem/A Description The winner of the card gam ...
- Codeforces Beta Round #2 A. Winner
A. Winner time limit per test 1 second memory limit per test 64 megabytes input standard input outpu ...
- codeforces Winner
/* * Winner.cpp * * Created on: 2013-10-13 * Author: wangzhu */ /** * 先找出所有选手的分数和中最大的分数和,之后在所有选手的分数和 ...
- Codeforces Gym100952 A.Who is the winner? (2015 HIAST Collegiate Programming Contest)
A. Who is the winner? time limit per test 1 second memory limit per test 64 megabytes input stan ...
- Codeforces Round #603 (Div. 2) C. Everyone is a Winner! 二分
C. Everyone is a Winner! On the well-known testing system MathForces, a draw of n rating units is ar ...
随机推荐
- AnimalWindow使用,实现界面动态消失
http://m.blog.csdn.net/blog/shufac/24932279 http://blog.sina.com.cn/s/blog_455245fc01000a42.html Ani ...
- hibernate载入持久化对象的两种方式——get、load
一.get与load对照 在hibernate中get和load方法是依据id取得持久化对象的两种方法.但在实际使用的过程中总会把两者混淆,不知道什么情况下使用get好,什么时候使用load方法效率更 ...
- OTT
http://baike.baidu.com/view/1315414.htm OTT 编辑 OTT 是“Over The Top”的缩写,是通信行业非常流行的一个词汇,这个词汇来源于篮球等体育运 ...
- npm的常用配置
第一次使用需要初始化 npm init -y npm-tut { "requires": true, "lockfileVersion": 1, "d ...
- 十天学习PHP之第二天
学习目的:学会构建数据库 在ASP中,假设是ACCESS数据库你能够直接打开ACCESS来编辑MDB文件,假设是SQL SERVER你能够打开企业管理器来编辑SQL SERVER数据库.可是在PHP ...
- linux以及git和maven常用命令
maven常用命令: clean install -Dmaven.test.skip -Ptest-lx (注意:test-lx是pom文件名) 其他 https://www.cnblogs.co ...
- JAVA 0 的突破
使用IntelliJ Idea 开发的一个Java 处理数据文件折行的问题,整体来说功能比较简单的一个java脚本的开发,跨平台的优势可以处理windows和lunix平台的文件折行 package ...
- (C)inline关键字
背景(C&C++中) 一.inline关键字用来定义一个类的内联函数,引入它的主要原因是用它替代C中表达式形式的宏定义. 表达式形式的宏定义一例:#define ExpressionNam ...
- Do not throw System.Exception, System.SystemException, System.NullReferenceException, or System.IndexOutOfRangeException intentionally from your own source code
sonarqube的扫描结果提示 https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/creatin ...
- MySQL性能优化-I/O相关配置参数
本文介绍InnoDB和MyISAM两种存储引擎的I/O相关参数配置. 1.InnoDB I/O相关配置 Innodb是一种事务型的存储引擎,为了减少提交事务时产生的io开销,innodb采用了写日志 ...