Codeforces Beta Round #2

简介: 点击打开链接 A /*思路:模拟分析:1 题目要求的在游戏结束后最大的点的值的玩家,或者具有相同点值的情况下最早出现*/#include#include#include#include#includeusing ...

点击打开链接


A

/*
思路:模拟
分析:
1 题目要求的在游戏结束后最大的点的值的玩家,或者具有相同点值的情况下最早出现

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;

#define MAXN 1010
#define N 50

int n , pos;
int vis[MAXN];
int p[MAXN];
char input[MAXN][N];
char name[MAXN][N];
map<string , int>mp;

int main(){
   int  max , cnt;
   while(scanf("%d%*c" , &n) != EOF){
      /*第一次输入*/
      for(int i = 0 ; i < n ; i++)
         scanf("%s %d%*c" , input[i] , &p[i]);

      /*第一次模拟*/
      max = 0 , pos = 0;
      for(int i = 0 ; i < n ; i++){
         int flag = -1;
         
         for(int j = 0 ; j < pos ; j++){
            if(!strcmp(name[j] , input[i])){
              flag = j;
              break;
            }
         }
         if(flag == -1)
            strcpy(name[pos++] , input[i]);
         mp[input[i]] += p[i];
      } 
      
      memset(vis , 0 , sizeof(vis));
      for(int i = 0 ; i < pos ; i++)
          max = max < mp[name[i]] ? mp[name[i]] : max;
      for(int i = 0 ; i < pos ; i++){
          if(max == mp[name[i]])
             vis[i] = 1;
      }
      
      /*第二次模拟*/
      mp.clear();
      for(int i = 0 ; i < n ; i++){
         mp[input[i]] += p[i];
         int tmp = 0;
         for(int i = 0 ; i < pos ; i++){
            if(tmp < mp[name[i]]){
               tmp = mp[name[i]];
               cnt = i;
            }
         }
         if(tmp >= max && vis[cnt])
             break;
      }

      printf("%s\n" , name[cnt]);
   }
   return 0;
}




目录
相关文章
Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861A k-rounding【暴力】
A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output ...
1229 0
Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861B Which floor?【枚举,暴力】
B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output...
1279 0
|
人工智能
Codeforces Beta Round #2 A,B,C
A. Winner time limit per test:1 second memory limit per test:64 megabytes input:standard input output:standard output ...
1207 0
|
Perl
Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard ...
852 0
|
机器学习/深度学习 Java Go
|
机器学习/深度学习 人工智能
容斥 + 组合数学 ---Codeforces Round #317 A. Lengthening Sticks
  Lengthening Sticks Problem's Link:  http://codeforces.com/contest/571/problem/A   Mean:  给出a,b,c,l,要求a+x,b+y,c+z构成三角形,x...
906 0
Codeforces Beta Round #7
点击打开链接 A #include #include #include #include using namespace std; #define N 8 char G[N][N]; int main(){ while(s...
797 0