欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PATB 1032 挖掘机技术哪家强(20)

程序员文章站 2024-01-30 19:22:28
#include #include using namespace std; const int N = 100001; vector school[N];//玩玩vector int sum[N]; int main() { int n,id,score; scanf("%d",&n); for(... ......
#include <cstdio>
#include <vector>
using namespace std;
const int N = 100001;
vector <int> school[N];//玩玩vector 
int sum[N]; 
int main()
{
	int n,id,score;
	scanf("%d",&n);
	for(int i = 0;i < n; i++)
	{
		scanf("%d%d",&id,&score);
		school[id].push_back(score);
	}
	int t = N;
	while(t--){
		for(vector<int>::iterator it = school[t].begin() ;it != school[t].end();it++)  
		{
			sum[t] += *it;
		}		
	}
	int max = sum[0];
	int num;
	for(int i = 0;i < N; i++)
	{
		if(sum[i] > max){
			max = sum[i];
			num = i;
		}
	}
	printf("%d %d",num,max);
	return 0;
}