题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
#include <iostream> #include <map> using namespace std; int main() { map<int, int> my_map; int key_num,key,value; cin >> key_num; for (int i=0; i < key_num; i++) { cin >> key >> value; my_map[key] +=value; } for (const auto& record : my_map) { cout << record.first << " " << record.second << endl; } return 0; }