답안 #524277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524277 2022-02-09T01:13:15 Z maks007 CONSUL (info1cup19_consul) C++14
100 / 100
42 ms 292 KB
#include <bits/stdc++.h>
#include <map>
#include "grader.h"
using namespace std;

void solve(int n)
{
	srand(time(0));
	map <int,int> mp;
	vector <int> used(n);
	set <int> s;
	if(n <= 50) {
		for(int i = 0; i < n; i ++) {
			int val = kth(i+1);
			mp[val] ++;
			if(mp[val] > n / 3) {
				say_answer(val);
				return;
			}
		}
		say_answer(-1);
		return;

	}
    for(int i = 0; i < 30; i ++) {
    	int val = rand() % n;
    	
    	int k = kth(val+1);
    	if(cnt(k) > n/3) {
    		say_answer(k);
    		return;
    	}
    	mp[k] ++;
    }

    say_answer(-1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 200 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 200 KB Output is correct
2 Correct 25 ms 200 KB Output is correct
3 Correct 8 ms 200 KB Output is correct
4 Correct 8 ms 200 KB Output is correct
5 Correct 24 ms 200 KB Output is correct
6 Correct 25 ms 200 KB Output is correct
7 Correct 22 ms 200 KB Output is correct
8 Correct 28 ms 200 KB Output is correct
9 Correct 22 ms 200 KB Output is correct
10 Correct 27 ms 292 KB Output is correct
11 Correct 28 ms 200 KB Output is correct
12 Correct 22 ms 200 KB Output is correct
13 Correct 23 ms 200 KB Output is correct
14 Correct 25 ms 200 KB Output is correct