Submission #341980

# Submission time Handle Problem Language Result Execution time Memory
341980 2020-12-31T21:19:09 Z cheissmart CONSUL (info1cup19_consul) C++14
100 / 100
29 ms 364 KB
#include "grader.h"
#ifdef CHEISSMART
#include "grader.cpp"
#endif
#include <bits/stdc++.h>

using namespace std;

void solve(int n) {
	set<int> asked;
	int qry = 0;
	auto is = [&] (int i) {
		int x = kth(i);
		qry++;
		if(asked.count(x)) return -1;
		asked.insert(x);
		qry++;
		if(cnt(x) * 3 > n) return x;
		else return -1;
	};
	mt19937 rng(time(0));
	while(qry + 2 <= 50) {
		int pos = rng() % n + 1;
		int r = is(pos);
		if(r != -1) {
			say_answer(r);
			return;
		}
	}
 	say_answer(-1);
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 364 KB Output is correct
2 Correct 25 ms 364 KB Output is correct
3 Correct 7 ms 364 KB Output is correct
4 Correct 9 ms 364 KB Output is correct
5 Correct 18 ms 364 KB Output is correct
6 Correct 25 ms 364 KB Output is correct
7 Correct 20 ms 364 KB Output is correct
8 Correct 27 ms 364 KB Output is correct
9 Correct 24 ms 364 KB Output is correct
10 Correct 29 ms 364 KB Output is correct
11 Correct 24 ms 364 KB Output is correct
12 Correct 24 ms 364 KB Output is correct
13 Correct 22 ms 364 KB Output is correct
14 Correct 20 ms 364 KB Output is correct