/ Randle /

记录详情

Runtime Error


  
# 状态 耗时 内存占用
#1 Wrong Answer 2ms 2.191 MiB
#2 Wrong Answer 1ms 2.297 MiB
#3 Accepted 2ms 2.203 MiB
#4 Wrong Answer 1ms 2.203 MiB
#5 Runtime Error 1ms 204.0 KiB
#6 Runtime Error 1ms 212.0 KiB
#7 Runtime Error 1ms 2.199 MiB
#8 Runtime Error 1ms 212.0 KiB
#9 Runtime Error 1ms 208.0 KiB
#10 Runtime Error 1ms 208.0 KiB

代码

#include<bits/stdc++.h>
using namespace std;
int Left[ 301000 ] , Right[ 301000 ],mid[ 301000 ];
int  a , b , n , MIN= 0x7777777 , MAX = -0x77777777 , ans = MIN;
int main(){
//	freopen("card.in","r",stdin);
//	freopen("card.out","w",stdout);
	scanf("%d",&n);
	for( int i = 1; i <= n ; i ++){
		scanf("%d%d", &a , &b );
		MIN = min(MIN , min( a , b ));
		MAX = max(MAX , max( a , b ));
		Left[ a ] ++ ;
	    Right[ b ] ++ ;
	    mid[ a ]++;
		mid[ b ]++; 
		if( a == b ) mid [ a ] -- ; 
    }
//    for ( int i = MIN ; i <= MAX ; i ++ ) 
//     cout << Left[ i ] << " "<< Right[ i ] <<" "<<mid[ i ]<<" "<<i<<endl;
    int  least = ( n + 1 ) / 2; 
    for( int i = MIN ; i <= MAX ; i ++ ) {
//    	int L = least - Left[ i ] , R = least - Right[ i ];
//  	cout<<L << " "<<R <<" "<<i <<endl;	
    	if( mid[ i ] >= least ) 
    		ans = min( ans , min( least - Left[ i ] , least - Right[ i ]));
	}
	if( ans < 0 ) ans = 0;
	if(ans == 0x7777777 )printf("Impossible");else
	printf("%d",ans);
	return 0;
} 

信息

递交者
类型
递交
题目
纸牌
题目数据
下载
语言
C++
递交时间
2019-12-13 15:33:29
评测时间
2019-12-13 15:33:29
评测机
分数
10
总耗时
16ms
峰值内存
2.297 MiB