// PATn.cpp : 定義控制臺應(yīng)用程序的入口點。
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
unsigned n = 0;
cin >> n;
map<string, unsigned> 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<pair<string, unsigned>> tmp_total_grade(total_grade.begin(), total_grade.end());
sort(tmp_total_grade.begin(), tmp_total_grade.end(), [&](pair<string, unsigned> lh, pair<string, unsigned> rh) {return lh.second > rh.second; });
cout << tmp_total_grade[0].first << " " << tmp_total_grade[0].second;
system("pause");
return 0;
}
1047
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
推薦閱讀更多精彩內(nèi)容
- 國內(nèi)路線: wget -chttps://api.sinas3.com/v1/SAE_lnmp/soft/lnmp...