/ Randle /

记录详情

Runtime Error

/in/foo.cc:7:15: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
 #define MAX 5 + 300000
             ~~^~~
/in/foo.cc:34:10: note: in expansion of macro 'MAX'
 int UpSm[MAX<<1],DwDf[MAX<<1];
          ^~~
/in/foo.cc:7:15: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
 #define MAX 5 + 300000
             ~~^~~
/in/foo.cc:34:23: note: in expansion of macro 'MAX'
 int UpSm[MAX<<1],DwDf[MAX<<1];
                       ^~~
# 状态 耗时 内存占用
#1 Accepted 3ms 6.305 MiB
#2 Accepted 3ms 6.195 MiB
#3 Accepted 3ms 6.207 MiB
#4 Accepted 3ms 6.195 MiB
#5 Accepted 11ms 6.504 MiB
#6 Wrong Answer 15ms 7.359 MiB
#7 Time Exceeded ≥1003ms ≥8.285 MiB
#8 Wrong Answer 79ms 8.305 MiB
#9 Runtime Error 2ms 2.195 MiB
#10 Runtime Error 2ms 4.195 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];
int UpSm[MAX<<1],DwDf[MAX<<1];

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:32
评测时间
2019-12-13 15:32:32
评测机
分数
50
总耗时
1128ms
峰值内存
8.305 MiB