PAT-乙-1047 1047 程式設計團體賽 (20 分)
阿新 • • 發佈:2018-12-13
程式碼
#include <iostream> #include <map> using namespace std; int main() { int n; scanf("%d", &n); map<int, int> m; int championNum = 0; int championScore = 0; for(int i=0; i<n; i++) { int team, member, score; scanf("%d-%d %d", &team, &member, &score); if(m[team]) { m[team] += score; } else { m[team] = score; } if(m[team]>championScore) { championNum = team; championScore = m[team]; } } printf("%d %d\n", championNum, championScore); return 0; }
註解
map的簡單使用。