[noj 1555] The Sum of F(x) and G(x)

簽到題。不知道校內賽新生們做的怎麼樣,雖然有着最高話語權的那個人毀掉了13新生們,不過我帶的幾個人不被污染就行了,其他就與我無關了-。-

按照指數加一下就行,由於太懶就直接開了個map

#include<iostream>
#include<cstdio>
#include<map>
using namespace std;

int main()
{
	int n, m;
	map<int, int> mp;
	int a, b;
	while(~scanf("%d%d", &n, &m))
	{
		mp.clear();
		for(int i = 0; i < n+m; i++)
		{
			scanf("%d%d", &a, &b);
			mp[b] += a;
		}
		map<int, int>::iterator it = mp.end();
		for(it--; it != mp.begin(); it--)
			printf("%d %d\n", it->second, it->first);
		printf("%d %d\n", it->second, it->first);
	}
	return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章