题解 | #合并表记录#使用map自带排序
#include <iostream> #include <map> using namespace std; int main() { int num; cin >> num; map<int, int> map_list; for (int i = 0; i < num; ++i) { int index, value; cin >> index >> value; map_list[index] += value; } for (auto it = map_list.begin(); it != map_list.end(); ++it) cout << it->first << " " << it->second << endl; return 0; } // 64 位输出请用 printf("%lld")