/ Randle /

记录详情

Runtime Error


  
# 状态 耗时 内存占用
#1 Accepted 1ms 200.0 KiB
#2 Accepted 1ms 208.0 KiB
#3 Accepted 1ms 332.0 KiB
#4 Accepted 1ms 212.0 KiB
#5 Accepted 14ms 632.0 KiB
#6 Accepted 59ms 3.957 MiB
#7 Runtime Error 88ms 7.266 MiB
#8 Runtime Error 28ms 1.512 MiB
#9 Runtime Error 47ms 5.215 MiB
#10 Runtime Error 22ms 1.27 MiB

代码

#include <bits/stdc++.h>
using namespace std;
map<int,int>f1;
map<int,int>f2;
map<int,int>f3;
int n;
int a[100005];
int cnt=0;
int main()
{
//    freopen("card.in","r",stdin);
//    freopen("card.out","w",stdout);
	int x,y;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&x,&y);
		if(x==y)
		{
		  f1[x]--;
	      a[++cnt]=x;
		}
		else
		{
			a[++cnt]=x;
			a[++cnt]=y;
		}
		f1[x]++;
		f1[y]++;
		f2[x]++;
	}
	int m=(n+1)/2,b=0;
	for(int i=1;i<=cnt;i++)
	{
//		cout<<a[i]<<' '<<f1[a[i]]<<' '<<f2[a[i]]<<endl;
		if(f1[a[i]]>=m)
		  b=1;
	}
	if(b==0)
	{
	  printf("Impossible");
      return 0;
	}
	int minn=1e9;
	for(int i=1;i<=cnt;i++)
	{
		if(f1[a[i]]>=m)
		  f3[a[i]]=m-f2[a[i]];
		else
		  f3[a[i]]=1e9;
		minn=min(minn,f3[a[i]]);
//		cout<<f[i].x<<' '<<f[i].y<<' '<<f[i].z<<endl;
	}
	printf("%d",minn);
	return 0;
}

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2019-12-13 15:31:44
评测时间
2019-12-13 15:31:44
评测机
分数
60
总耗时
267ms
峰值内存
7.266 MiB