5 1 3 2 3 3 11 1 1 1 1 1 5 5 5 5 5 5 7 1 1 1 1 1 1 1
3 5 1
#include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> using namespace std; #define ll long long int n, a[1000000+8], sign[1000000+8]; int main() { while(~scanf("%d", &n)) { memset(sign, 0, sizeof(sign)); int miao, ga; for(int i = 0; i<n; i++) { scanf("%d", &a[i]); sign[a[i]]++; if(sign[a[i]] == (n+1)/2) { miao = a[i]; ga = i; } } printf("%d\n", a[ga]); } return 0; }
SDNU 1095.Ignatius and the Princess IV(水题)
原文:https://www.cnblogs.com/RootVount/p/10891071.html