/ Randle /

记录详情

Runtime Error


  
# 状态 耗时 内存占用
#1 Accepted 2ms 4.195 MiB
#2 Accepted 2ms 4.199 MiB
#3 Accepted 2ms 4.207 MiB
#4 Accepted 2ms 4.312 MiB
#5 Accepted 10ms 4.309 MiB
#6 Wrong Answer 13ms 5.258 MiB
#7 Time Exceeded ≥1005ms ≥5.926 MiB
#8 Wrong Answer 74ms 6.02 MiB
#9 Runtime Error 2ms 2.191 MiB
#10 Runtime Error 2ms 4.191 MiB

代码

#include<bits/stdc++.h>
#define fre(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout);

#define IsDigit(c) ('0'<=(c) && (c)<='9')

#define MAX 5 + 300000

#define INF 1<<30

using namespace std;

inline int read()
{
	int x=0; bool f=true;
	char c=getchar();
	for (;!IsDigit(c);c=getchar()) if (c=='-') f=false;
	for (;IsDigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	return f ? x : -x;
}
inline void write(int x)
{
    if (x<0)
	{
        putchar('-');
		x=-x;
	}
    if (x>9) write(x/10);
	putchar(x%10+'0');
}

int n,Half,cnt,Ans=INF;
int a[MAX],b[MAX],Num[MAX];
int UpSm[MAX],DwDf[MAX];

signed main()
{
//	fre(card);

	n=read();  Half=(n+1)>>1;
	for (register int i=1;i<=n;i++)
	{
		a[i]=read(); b[i]=read();
		if (a[i]==b[i]) UpSm[a[i]]++;
		   else UpSm[a[i]]++,DwDf[b[i]]++;
		Num[++cnt]=a[i]; Num[++cnt]=b[i];
	}
	sort(Num+1,Num+cnt+1);
	for (register int x,y,i=1;i<=cnt;i++)
	{
		x=UpSm[Num[i]],y=DwDf[Num[i]];
		if (x+y>=Half) Ans=min(Ans,max(Half-x,0));
	}
	if (Ans==INF) puts("Impossible");
	    else write(Ans);

	return 0;
}

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2019-12-13 15:32:03
评测时间
2019-12-13 15:32:03
评测机
分数
50
总耗时
1118ms
峰值内存
6.02 MiB