B1032. 挖掘机技术哪家强

B1032. 挖掘机技术哪家强_第1张图片

 

 

 题目思路

  • 搞一个数组就解决了
#include 

using namespace std;

const int maxn = 100010;

int school[maxn] =  {0};
int main(int argc, char* argv[]) {
    int N, id, score, max_id, max_score = 0;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> id >> score;
        school[id] += score;    
    }
    for(int i = 0; i < N; i++){
        if(school[i] > max_score){
            max_id = i;
            max_score = school[i];
        }
    }
    cout << max_id << ' ' << max_score << endl;
    return 0;
}

你可能感兴趣的:(B1032. 挖掘机技术哪家强)