挖掘机技术哪家强

来源:互联网 发布:安卓小说阅读器源码 编辑:程序博客网 时间:2024/04/18 14:28

题目描述

为了用事实说明挖掘机技术到底哪家强,组织一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。

输入

输入在第1行给出不超过105的正整数N,即参赛人数。随后N行,每行给出一位参赛者的信息和成绩,包括其所代表的学校的编号(从1开始连续编号)、及其比赛成绩(百分制),中间以空格分隔。

输出

在一行中给出总得分最高的学校的编号、及其总分,中间以空格分隔。题目保证答案唯一,没有并列。

样例输入

63 652 801 1002 703 403 0

样例输出

2 150

#include<iostream>using namespace std;int main(){int n,max=0,index=0;int i = 0;int id;int temp_score;int score[100000] = {0};cin >> n;for (i = 0; i < n; i++){cin >> id >> temp_score;score[id] = temp_score + score[id];}for (i = 0; i <100000; i++){if (score[i] >= max){max = score[i];index = i;}}if (n >0&&n<=100000){cout << index << ' ' << max;}return 0;}


0 0
原创粉丝点击