题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
#include <iostream> using namespace std; #include <map> int main() { //使用有序关联容器,其中的值不能重复, map来实现 map<int, int> word_count; int N = 0; cin >> N; for (int i = 0; i<N; i++) { int a,b; cin>>a>>b; word_count[a] +=b; } for(auto w: word_count) { cout<<w.first <<' '<< w.second << endl; } return 0; } // 64 位输出请用 printf("%lld")