/ Randle /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 1ms 204.0 KiB
#2 Wrong Answer 1ms 200.0 KiB
#3 Wrong Answer 1ms 212.0 KiB
#4 Wrong Answer 1ms 208.0 KiB
#5 Wrong Answer 1ms 208.0 KiB
#6 Wrong Answer 1ms 204.0 KiB
#7 Wrong Answer 1ms 212.0 KiB
#8 Wrong Answer 1ms 204.0 KiB
#9 Wrong Answer 1ms 208.0 KiB
#10 Wrong Answer 1ms 204.0 KiB

代码

#include <utility>
#include <cstdio>
#include <cmath>
#include <map>

typedef std::pair<long long,long long> count;

std::map<long long,count> c;

int main()
{
	freopen("card.in","r",stdin);
	freopen("card.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		c[a].first++;
		if(a!=b)
		{
			c[b].first++;
			c[b].second++;
		}
	}
	long long min=0x7fffffffffffffff;
	long long need=(n+1)>>1;
	for(std::map<long long,count>::iterator i=c.begin();i!=c.end();i++)
		if((i->second).first>=need)
			min=std::min(min,std::max(0LL,need-(i->second).first+(i->second).second));
	if(min==0x7fffffffffffffff) puts("Impossible");
	else printf("%lld\n",min);
	return 0;
}

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2019-12-13 16:28:16
评测时间
2019-12-13 16:28:16
评测机
分数
0
总耗时
12ms
峰值内存
212.0 KiB