1. 程式人生 > >PAT乙級挖掘機技術哪家強

PAT乙級挖掘機技術哪家強

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <stack>

using namespace std;

//const int MaxSize = 10100;
const
long long MaxSize1 = 100010; typedef struct { long long id = 0; //int score; long long sum = 0; }Sch; Sch sch[MaxSize1]; int Size = 0; bool cmp(Sch schc1, Sch schc2) { if (schc1.sum != schc2.sum) { return schc1.sum > schc2.sum; } return 0; } int main() { // freopen("Text.txt", "r", stdin);
long long n = 0; while (scanf("%lld",&n)!=EOF ) { long long tpscore = 0; long long tpId = 0, max = 0; for (int i = 0; i < n; i++) { scanf("%lld %lld", &tpId, &tpscore); sch[tpId].id = tpId; sch[tpId].sum += tpscore; max = max>tpId?max:tpId; } sort(sch + 1
, sch + max+1,cmp); printf("%lld %lld\n", sch[1].id, sch[1].sum); memset(sch, 0, sizeof(sch)); } return 0; }

記住 了 10 的5次方是1後面5個零 共 六位數 唉 錯了無數次了