#include<iostream>
using namespace std;
#include<map>
int main(){
int n;
cin >> n;
map<int,int>m;
for(int i = 0; i < n; i++){
pair<int,int>item;
cin >> item.first;
cin >> item.second;
if(m.find(item.first) != m.end()){//找到了相同索引
m[item.first] += item.second;//合并后的键值对(多行
}else{
m[item.first] = item.second;
}
}
for(auto it = m.begin(); it != m.end(); it++){
cout << it->first << ' '<< it->second << endl;
}
return 0;
}
06-03
229
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-14