题目:Click here
题意:bestcoder上面有中文题目
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #include <string> 7 #include <climits> 8 #include <vector> 9 #include <queue> 10 #include <stack> 11 #define F first 12 #define S second 13 typedef long long ll; 14 using namespace std; 15 const double PI = 3.14159265; 16 const double E = 2.718281828459; 17 const double EPS=1e-8; 18 const int M = 1e5+5; 19 const int MOD = 1e9+7; 20 const int INF = 0x3f3f3f3f; 21 22 int n; 23 int a[M]; 24 int main() { 25 #ifdef ONLINE_JUDGE 26 #else 27 freopen( "in.txt", "r", stdin ); 28 #endif 29 while( ~scanf("%d", &n ) ) { 30 memset( a, 0, sizeof(a) ); 31 for( int i=0; i<n; i++ ) { 32 int x; 33 scanf("%d", &x ); 34 a[x]++; 35 } 36 bool ok = true; 37 bool first = true; 38 for( int i=0; i<=1e5; i++ ) { 39 if( a[i] > n-a[i] ) { 40 if( first ) { 41 ok = false; 42 first = false; 43 printf("%d", i ); 44 } 45 else { 46 printf(" %d", i ); 47 } 48 } 49 } 50 if( ok ) 51 printf("-1"); 52 printf("\n"); 53 } 54 return 0; 55 }
时间: 2024-10-22 04:11:28