/ Randle /

记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Accepted 2ms 2.195 MiB
#2 Accepted 1ms 2.301 MiB
#3 Accepted 1ms 340.0 KiB
#4 Accepted 1ms 332.0 KiB
#5 Accepted 11ms 2.668 MiB
#6 Accepted 54ms 6.07 MiB
#7 Time Exceeded ≥1004ms ≥9.395 MiB
#8 Wrong Answer 148ms 4.578 MiB
#9 Wrong Answer 432ms 9.668 MiB
#10 Wrong Answer 149ms 6.566 MiB

代码

#pragma GCC optimize(2)
#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];
map<unsigned short int,unsigned short int>UpSm,DwDf;

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:34:36
评测时间
2019-12-13 15:34:36
评测机
分数
60
总耗时
≥1806ms
峰值内存
≥9.668 MiB