/ Randle /

记录详情

Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:39:2: error: 'else' without a previous 'if'
  else printf("%lld\n",min);
  ^~~~
/in/foo.cc:39:23: error: 'min' was not declared in this scope
  else printf("%lld\n",min);
                       ^~~
/in/foo.cc:39:23: note: suggested alternative:
In file included from /usr/include/c++/6/bits/stl_tree.h:63:0,
                 from /usr/include/c++/6/map:60,
                 from /in/foo.cc:4:
/usr/include/c++/6/bits/stl_algobase.h:243:5: note:   'std::min'
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~

代码

#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);
	bool check=false;
	long long need=(n+1)>>1;
	for(int i=0;i<n;i++)
	{
		long long a,b;
		scanf("%lld%lld",&a,&b);
		c[a].first++;
		if(a!=b)
		{
			c[b].first++;
			c[b].second++;
		}
		if(c[a].first>=need) check|=true;
		if(c[b].first>=need) check|=true;
	}
	if(!check) puts("Impossible");
	else
	{
		long long min=need;
		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));
	}
	else printf("%lld\n",min);
	return 0;
}

信息

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