Ignatius and the Princess IV
///@author Sycamore ///@date 8/8/2017 #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; while (cin >> n) { map<int, int>v; int t,ans=-1; for (int i = 1; i <=n; i++) { cin >> t; if(ans==-1) if (++v[t] >= ((n + 1) >> 1)) ans = t; } cout << ans << endl; } return 0; }
时间: 2024-10-11 23:18:15