HJ8 合并表记录 | 杂乱无章的初级程序员的题解
#include <iostream>
#include <map>
using namespace std;
int main()
{
uint32_t n;
cin >> n;
map<uint32_t, uint32_t> m;
for (uint32_t i = 0; i < n; ++i) {
uint32_t key, value;
cin >> key >> value;
m[key] += value;
}
for (auto &i : m) {
cout << i.first << " " << i.second << endl;
}
}
#华为机试#