1047

// PATn.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include
#include
#include
#include
#include


using namespace std;

int main()
{
    unsigned n = 0;
    cin >> n;

    map total_grade;
    string tmp1;
    unsigned tmp2;
    
    for (unsigned i = 0; i < n; ++i)
    {
        cin >> tmp1 >> tmp2;
        string tmp1_tmp = tmp1.substr(0, tmp1.find("-"));
        if (total_grade.find(tmp1_tmp) != total_grade.cend())
        {
            total_grade.at(tmp1_tmp) += tmp2;
        }
        else
        {
            total_grade[tmp1_tmp] = tmp2;
        }
    }

    vector> tmp_total_grade(total_grade.begin(), total_grade.end());
    sort(tmp_total_grade.begin(), tmp_total_grade.end(), [&](pair lh, pair rh) {return lh.second > rh.second; });

    cout << tmp_total_grade[0].first << " " << tmp_total_grade[0].second;
    

    system("pause");
    return 0;
}

你可能感兴趣的:(1047)