/ Randle /

记录详情

Runtime Error


  
# 状态 耗时 内存占用
#1 Accepted 2ms 332.0 KiB
#2 Accepted 1ms 380.0 KiB
#3 Accepted 2ms 460.0 KiB
#4 Accepted 1ms 396.0 KiB
#5 Runtime Error 2ms 488.0 KiB
#6 Runtime Error 3ms 848.0 KiB
#7 Runtime Error 3ms 860.0 KiB
#8 Runtime Error 2ms 660.0 KiB
#9 Runtime Error 2ms 680.0 KiB
#10 Runtime Error 2ms 516.0 KiB

代码

//
/*
Author : Zmonarch
Knowledge :
*/
#include <bits/stdc++.h>
#define inf 2147483647
#define int long long
using namespace std ;
const int N = 3e3 + 10 ;
int read() {
	int x = 0 , f = 1 ; char ch = getchar() ;
	while(!isdigit(ch)) {if(ch == '-') f = - 1 ; ch = getchar() ;}
	while( isdigit(ch)) {x = x * 10 + ch - '0' ; ch = getchar() ;}
	return x * f ;
}
int n , m , tot , Ans = inf ; 
bool tag ; 
map <int , int> cnt1 , cnt2 ;
int a[N] , b[N] , num[N]; 
signed main() {
//	freopen("card.in" , "r" , stdin) ; 
//	freopen("card.out" , "w" , stdout) ;
	n = read() ; 
	for(int i = 1 ; i <= n ; i++)
	{
		a[i] = read() , b[i] = read() ; 
		if(a[i] ^ b[i]) cnt1[a[i]]++ , cnt2[b[i]]++; 
		else cnt1[a[i]]++ ; 
		num[++tot] = a[i] ; num[++tot] = b[i] ; 
	}
	sort(num + 1 , num + tot + 1) ; 
	for(int i = 1 ; i <= n ; i++) 
	{
		int kx = cnt1[a[i]] , ky = cnt2[a[i]] ;
		if(kx + ky >= (n + 1) / 2) tag = 1 , Ans = min(Ans , max(0ll , (n + 1) / 2 - kx)) ;
	}
	if(tag) printf("%lld\n" , Ans) ; 
	else printf("Impossible\n") ; 
	//fclose(stdin) ; fclose(stdout) ; 
	return 0 ;
} 

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2021-10-28 14:19:41
评测时间
2021-10-28 14:19:41
评测机
分数
40
总耗时
26ms
峰值内存
860.0 KiB