/ Randle /

记录详情

Time Exceeded


  
正在同步测试数据,请稍后
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 1ms 384.0 KiB
#2 Accepted 1ms 384.0 KiB
#3 Accepted 2ms 512.0 KiB
#4 Accepted 2ms 384.0 KiB
#5 Accepted 9ms 1.926 MiB
#6 Accepted 76ms 6.457 MiB
#7 Time Exceeded ≥1623ms ≥33.945 MiB
#8 Accepted 185ms 10.832 MiB
#9 Accepted 717ms 37.02 MiB
#10 Accepted 150ms 13.914 MiB

代码

//
/*
Author : Zmonarch
Knowledge :
*/
#include <bits/stdc++.h>
#define inf 2147483647
#define int long long
using namespace std ;
const int N = 1e6 + 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:21:46
评测时间
2021-10-28 14:21:46
评测机
分数
90
总耗时
≥2771ms
峰值内存
≥37.02 MiB