帮帮萌新
  • 板块CF2A Winner
  • 楼主mtj295152
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/11/23 11:30
  • 上次更新2023/10/27 01:51:30
查看原帖
帮帮萌新
721058
mtj295152楼主2022/11/23 11:30
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main()
{
    int max = -1, max_t = 10000;
    string max_n;
    map<string, pair<int, int>>arr;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string name;
        int score;
        cin >> name >> score;
        arr[name] = make_pair(arr[name].first + score, i);
    }
    for (auto it = arr.begin(); it != arr.end(); it++)
    {
        int num = it->second.first;
        int turn = it->second.second;
        string name = it->first;
        if (max < num) {
            max = num;
            max_n = name;
            max_t = turn;
        }
        else if (max == num) {
            if (max_t > turn) {
                max_n = name;
                max_t = turn;
            }
        }
    }
    cout << max_n << endl;
}

为甚么case6过不去啊

2022/11/23 11:30
加载中...