题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
cin >> n;
map<int, int> sum_map;
while (n--) {
cin >> a >> b;
sum_map[a] += b;
}
for (auto cur : sum_map)
cout << cur.first << " " << cur.second << endl;
}
// 64 位输出请用 printf("%lld")
查看29道真题和解析