Codeforces Beta Round 2 A题:Winner

题目传送门

这道题我开始准备使用map+stable_sort来做,但是无论是map或是unorder_map,都会改变输入的顺序,导致某一组答案错误。

所以我们可以使用map来进行纯模拟的操作。

首先,在输入的同时把最终各个人的分数加起来,然后找到最大值。

其次,再次模拟一遍游戏,当找到第一个达到m且最终的分数也大于等于m的人,输出即可。

12345678910111213141516171819202122232425262728293031323334
#define rep(i,a,n) for(int i=a;i<n;++i)#define pb push_back#define close() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)using namespace std;typedef long long ll;typedef pair<string,int>P;map<string,int>mp,mmp;vector<string>v1;vector<int>v2;

int (){    close();    int n,m;    string s;    cin>>n;    rep(i,0,n){        cin>>s>>m;        v1.pb(s);v2.pb(m);        mp[s]+=m;    }    m=0;    for(auto &x:mp) m=max(m,x.second);  

rep(i,0,n){        mmp[v1[i]]+=v2[i];        if(mmp[v1[i]]>=m&&mp[v1[i]]>=m){             cout<<v1[i]<<endl;            break;        }    }    return 0;}

原文:大专栏  Codeforces Beta Round 2 A题:Winner

原文地址:https://www.cnblogs.com/chinatrump/p/11423846.html

时间: 2024-07-29 18:40:35

Codeforces Beta Round 2 A题:Winner的相关文章

水题 Codeforces Beta Round #70 (Div. 2) A. Haiku

题目传送门 1 /* 2 水题:三个字符串判断每个是否有相应的元音字母,YES/NO 3 下午网速巨慢:( 4 */ 5 #include <cstdio> 6 #include <cstring> 7 #include <string> 8 #include <iostream> 9 #include <algorithm> 10 #include <cmath> 11 using namespace std; 12 13 cons

CodeForces Beta Round #1

Codeforces Beta Round #1 A. Theatre Square [题意]一个n*m的矩形广场,用a*a的方形石板铺设,问最少需要多少块石板能铺满广场. [思路]水题,从n方向来看能能够铺设ceil(n/a)块,从m方向来看能能够铺设ceil(m/a)块,总共有ceil(n/a)*ceil(m/a)块. 1 /* 2 ** CodeForces 1A Theatre Square 3 ** Created by Rayn @@ 2014/05/18 4 */ 5 #inclu

Codeforces Beta Round #1 B. Spreadsheets

Codeblocks坏掉了,我不知道该怎么修,只能过两天重装系统了. 没办法.这个题是用Java写的,代码风格不好不要骂我~~ 题目大意: Excel表格那种坐标系统,和正常的坐标系统.用代码实现转换. 就是模拟题啊,代码量比较小. 下面是代码: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); i

Codeforces Beta Round#2

Codeforces Beta Round#2 http://codeforces.com/contest/2 A 模拟题 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 5 map<string,ll>mp; 6 struct sair{ 7 string str; 8 int id; 9 ll num; 10 }a[1005]; 11 12 bool cmp(sair a,sa

Codeforces Beta Round #3

Codeforces Beta Round #3 http://codeforces.com/contest/3 A 找规律题.但我懒得找,直接暴搜 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 typedef long long ll; 7 /*

Codeforces Beta Round #5

Codeforces Beta Round #5 http://codeforces.com/contest/5 A 模拟题 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 typedef long long ll; 7 /*#ifndef ONLI

Codeforces Beta Round #6 (Div. 2 Only)

Codeforces Beta Round #6 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 1000010 7 typedef long long ll; 8 /*#ifndef

Codeforces Beta Round #7

Codeforces Beta Round #7 http://codeforces.com/contest/7 A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 1000010 7 typedef long lon

Codeforces Beta Round #9 (Div. 2 Only)

Codeforces Beta Round #9 (Div. 2 Only) http://codeforces.com/contest/9 A gcd水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 1000010 7