PAT(乙级) 编程团体赛

偶尔善良 提交于 2020-02-14 18:03:54

题目

题目链接

思路

还是用数组存分数,下标为队伍的编号

代码

#include <iostream>
using namespace std;
int main(){
    int cnt;
    cin >> cnt;
    int ID[1001] = {0};
    int max = 0;
    while(cnt){
        --cnt;
        string s;
        int grade=0,id=0;
        cin >> s >> grade;
        id = stoi(s.substr(0,s.find_first_of('-',0)-0));
        ID[id] += grade;
        if(ID[id] > ID[max]) max = id;
    }
    cout << max << " " << ID[max];
    return 0;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!