/ Randle /

记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Accepted 9ms 348.0 KiB
#2 Accepted 3ms 384.0 KiB
#3 Accepted 3ms 384.0 KiB
#4 Accepted 7ms 384.0 KiB
#5 Accepted 28ms 696.0 KiB
#6 Accepted 61ms 7.0 MiB
#7 Wrong Answer 536ms 35.75 MiB
#8 Accepted 214ms 3.5 MiB
#9 Accepted 409ms 29.953 MiB
#10 Accepted 170ms 6.742 MiB

代码

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

const int N=300005;

map<int,int> M0,M1;
int A[2*N];
int n,m,ans=N;

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		int a,b;
		scanf("%d %d",&a, &b);
		if (a==b) M0[a]++;//¼Ç¼aµÄ´ÎÊý
		else M0[a]++, M1[b]++;
		A[++m]=a;//½«ËùÓгöÏÖµÄÊý¶¼·ÅÔÚA[]ÖÐ
		A[++m]=b;
	}
	sort(A+1,A+m+1);
	for (int i=1; i<=m; i++)//ö¾ÙÔÚ×îÖÕÒª·­µÄÅÆÃæÊý×Ö
	{
		int x=M0[A[i]],y=M1[A[i]];
		if (x+y>=(n+1)/2)
			ans=min(ans,max((n+1)/2-x,0));
	}
	if (ans==N)
		printf ("Impossible\n"); 
	else
		printf("%d\n",ans);
	return 0;
}

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2018-10-04 22:31:50
评测时间
2018-10-04 22:31:50
评测机
分数
90
总耗时
1443ms
峰值内存
35.75 MiB