Submission #364141

#TimeUsernameProblemLanguageResultExecution timeMemory
364141yasseenkamelCONSUL (info1cup19_consul)C++14
100 / 100
44 ms748 KiB
#include <bits/stdc++.h> #include "grader.h" //#include "grader.cpp" using namespace std; map<int,int> vis; void solve(int n){ int a[1005]; if(n <= 50){ for(int i = 0 ; i < n ; i ++){ int x = kth(i + 1); a[i] = x; } sort(a,a + n); int cnt = 1; for(int i = 1 ; i < n ; i ++){ if(a[i] != a[i - 1]){ if(cnt > n / 3){ say_answer(a[i - 1]); //cout << a[i - 1] << endl; return; } cnt = 0; } cnt ++; //cout << a[i] << " " << cnt << endl; } if(cnt > n / 3){ say_answer(a[n - 1]); return; } say_answer(-1); return; } for(int i = 0 ; i < 30 ; i ++){ int idx = (rand() % n) + 1; int x = kth(idx); if(!vis[x]){ int y = cnt(x); if(y > n / 3){ say_answer(x); return; } } } //sort(a,a + n); //int cnt = 1; say_answer(-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...