5 2 3 3 2 4 2 2 1 2 1
2 5 3 2 4 2
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
map<string,int>q;
struct P
{
string s;
int num;
}hehe[10000];
bool cmd(P x,P y)
{
if(x.s<y.s)
return 1;
return 0;
}
int main()
{
int t;
int i;
string s;
int num;
while(cin>>t)
{
for(i=0;i<t;i++)
{
cin>>hehe[i].s>>hehe[i].num;
q[hehe[i].s]+=hehe[i].num;
}
// cout<<q.size()<<endl;
map<string,int>::iterator it;
for(it=q.begin();it!=q.end();it++)
{
cout<<it->first<<" "<<it->second<<endl;
}
q.clear();
}
return 0;
}
湖南工业大学创新实验室2015年新生赛(一)1009(重开)
原文:http://www.cnblogs.com/yinghualuowu/p/4996018.html