/ Randle /

记录详情

Wrong Answer

/in/foo.cc: In function 'int main()':
/in/foo.cc:28:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if((i->second).first>=(n+1)/2)
      ~~~~~~~~~~~~~~~~~^~~~~~~~~
# 状态 耗时 内存占用
#1 Accepted 1ms 204.0 KiB
#2 Accepted 1ms 204.0 KiB
#3 Accepted 1ms 336.0 KiB
#4 Accepted 1ms 208.0 KiB
#5 Accepted 11ms 296.0 KiB
#6 Accepted 39ms 3.27 MiB
#7 Wrong Answer 697ms 22.402 MiB
#8 Accepted 135ms 920.0 KiB
#9 Wrong Answer 515ms 18.539 MiB
#10 Accepted 113ms 2.941 MiB

代码

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

typedef std::pair<unsigned int,unsigned int> count;

std::map<unsigned int,count> c;

int main()
{
	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++;
		}
	}
	unsigned int min=0xfffffffe;
	unsigned int need=(n+1)/2;
	for(std::map<unsigned int,count>::iterator i=c.begin();i!=c.end();i++)
		if((i->second).first>=(n+1)/2)
			min=std::min(min,std::max(0U,need-(i->second).first+(i->second).second));
	if(min==0xfffffffe) puts("Impossible");
	else printf("%u\n",min);
	return 0;
}

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2019-12-13 14:54:50
评测时间
2019-12-13 14:54:50
评测机
分数
80
总耗时
1519ms
峰值内存
22.402 MiB