답안 #246298

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246298 2020-07-08T15:15:25 Z lovemathboy CONSUL (info1cup19_consul) C++14
85 / 100
74 ms 416 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

void solve(int n)
{
	vector<int> r;
	for (int i = 1; i <= n; i++) r.push_back(i);
	random_shuffle(r.begin(), r.end());
	map<int, int> m;
	set<int> s;
	for (int i = 0; i < min(n, 50); i++) {
		int val = kth(r[i]);
		m[val]++;
		s.insert(val);
	}
	vector<pair<int, int> > totals;
	for (int i: s) {
		totals.emplace_back(-m[i], i);
	}
	sort(totals.begin(), totals.end());
	for (int i = 0; i < min((int)totals.size(), 10); i++) {
		if (-totals[i].first > n/3) {
			say_answer(totals[i].second);
			return;
		}
		if (cnt(totals[i].second) > n/3) {
			say_answer(totals[i].second);
			return;
		}
	}
	say_answer(-1);
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 60 ms 256 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 384 KB Output is correct
2 Correct 48 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 384 KB Output is correct
2 Correct 51 ms 384 KB Output is correct
3 Correct 46 ms 256 KB Output is correct
4 Correct 46 ms 256 KB Output is correct
5 Correct 43 ms 372 KB Output is correct
6 Correct 60 ms 256 KB Output is correct
7 Correct 71 ms 384 KB Output is correct
8 Correct 68 ms 256 KB Output is correct
9 Correct 49 ms 256 KB Output is correct
10 Correct 73 ms 384 KB Output is correct
11 Correct 74 ms 256 KB Output is correct
12 Correct 62 ms 416 KB Output is correct
13 Correct 70 ms 256 KB Output is correct
14 Correct 71 ms 256 KB Output is correct