Submission #362623

#TimeUsernameProblemLanguageResultExecution timeMemory
362623Tenis0206CONSUL (info1cup19_consul)C++14
4.96 / 100
3090 ms492 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; /*static const int MIN_VALUE = 0, MAX_VALUE = (1e9) - 1; static map<int,int> mp; static int Q, N, a[5005]; static bool issol, answer; void say_answer(int k) { cout<<k<<'\n'; } int cnt(int k) { ++Q; if(!(k>=MIN_VALUE && k<=MAX_VALUE)) { cout << "Wrong query format\n"; exit(0); } return mp[k]; } int kth(int k) { ++Q; if(!(k>=1 && k<=N)) { cout << "Wrong query format\n"; exit(0); } return a[k]; } */ void solve(int n) { map<int,bool> sel; for(int i=1; i<=50; i++) { int x = 0; while(!x || sel[x]) { x = rand()%n + 1; } int val = kth(x); int nr = cnt(val); sel[x]=true; if(nr>n/3) { say_answer(val); return; } } say_answer(-1); } /*int main() { int tests, i; cin >> tests; while(tests--) { cin >> N; mp.clear(); Q = 0; issol = 0; answer = 0; for(i=1; i<=N; ++i) cin >> a[i], ++mp[a[i]]; for(i=1; i<=N; ++i) issol |= (mp[a[i]] > N/3); solve(N); } return 0; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...