1032

作者: 峡迩 | 来源:发表于2017-08-21 17:18 被阅读0次
    
    #include "stdafx.h"
    
    #include<iostream>
    #include<vector>
    #include<map>
    #include<utility>
    
    using namespace std;
    
    
    
    int main()
    {
    
    
        map<int, vector<int>> info;
    
        int n = 0;
        int number = 0;
        int grade = 0;
    
        cin >> n;
    
        for (int i = 0; i < n; ++i)
        {
            cin >> number >> grade;
            info[number].push_back(grade);
        }
    
        int good_grades = 0;
        pair<int, vector<int>> good_school;
    
        for (auto &r : info)
        {
            int sum = 0;
            for (auto &k : r.second)
            {
                sum = sum + k;
            }
            if (sum > good_grades)
            {
                good_grades = sum;
                good_school = r;
            }   
        }
    
        cout << good_school.first << " " << good_grades;
    
    
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:1032

          本文链接:https://www.haomeiwen.com/subject/bqkhdxtx.html