/ Randle /

记录详情

Memory Exceeded


  
# 状态 耗时 内存占用
#1 Accepted 4ms 8.301 MiB
#2 Accepted 3ms 6.309 MiB
#3 Wrong Answer 3ms 6.309 MiB
#4 Wrong Answer 3ms 6.195 MiB
#5 Accepted 13ms 6.461 MiB
#6 Time Exceeded ≥1001ms ≥10.609 MiB
#7 Time Exceeded ≥1002ms ≥9.195 MiB
#8 Wrong Answer 968ms 11.512 MiB
#9 Memory Exceeded ≥213ms ≥256.0 MiB
#10 Wrong Answer 431ms 233.133 MiB

代码

#include<bits/stdc++.h>
using namespace std;
int n,l,cnt,need,maxx,x[300010],y[300010];
int b[700010],c[700010],d[30],e[30];
bool v[1000000010];
int main()
{
//	freopen("card.in","r",stdin);
//	freopen("card.out","w",stdout);
	scanf("%d",&n);
	need=(n+1)/2;
	for (int i=1;i<=n;i++) {
		scanf("%d%d",&x[i],&y[i]);
		if (!v[x[i]]) {
			v[x[i]]=1;
			b[++cnt]=x[i];
			c[cnt]=1;
			if (1>=maxx) {
			   	if (1==maxx) l++;
				else l=1;
				d[l]=x[i];
			 	maxx=1;
			}
		}
		else {
			for (int j=1;j<=cnt;j++)
			    if (b[j]==x[i]) {
			    	c[j]++;
			    	if (c[j]>=maxx) {
			    		if (c[j]==maxx) l++;
						else l=1;
						d[l]=x[i];
			    		maxx=c[j];
					}
			    	break;
				}
		}
		if (!v[y[i]]) {
			v[y[i]]=1;
			b[++cnt]=y[i];
			c[cnt]=1;
			if (1>=maxx) {
			   	if (1==maxx) l++;
				else l=1;
				d[l]=y[i];
			 	maxx=1;
			}
		}
		else {
			for (int j=1;j<=cnt;j++)
			    if (b[j]==y[i]) {
			    	c[j]++;
			    	if (c[j]>=maxx) {
			    		if (c[j]==maxx) l++;
						else l=1;
						d[l]=y[i];
			    		maxx=c[j];
					}
			    	break;
				}
		}
	}
	if (maxx<need) {
		puts("Impossible");
		return 0;
	}
	maxx=0;
	for (int i=1;i<=n;i++)
	    for (int j=1;j<=l;j++)
	        if (x[i]==d[j]) {
	        	e[j]++;
	        	maxx=max(maxx,e[j]);
			}
	printf("%d",max(0,need-maxx));
}

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2019-12-13 14:52:21
评测时间
2019-12-13 14:52:21
评测机
分数
30
总耗时
≥3646ms
峰值内存
≥256.0 MiB