#include <iostream>
#include <map> //map会自动按照key升序排列元素
using namespace std;
int main()
{
int n; cin >> n;
map<int,int> M;
for(int i = 0; i < n; i++)
{
int key,value;
cin>>key; cin>>value;
M[key] = value + M[key];
}
//输出
auto itr = M.begin();
while(itr != M.end())
{
cout<<(*itr).first<<' '<<(*itr).second<<endl;
++itr;
}
return 0;
}

京公网安备 11010502036488号