题解 | #合并表记录#

合并表记录

https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201

#include<iostream>
#include<map>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	map<int, int>maps;
	int n;
	cin >> n;
	map<int, int>::iterator it;
	for (int i = 1; i <= n; ++i)
	{
		int k, v;
		cin >> k >> v;
		maps[k] += v;
		//maps[k] += v;
	}
	for (auto c : maps)
		cout << c.first << " " << c.second << endl;
	/*for (it=maps.begin();it!=maps.end();it++)
	{
		cout << it->first << " " << it->second << endl;
	}*/
	return 0;
}

全部评论

相关推荐

仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
投递拓竹科技等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务