Submission #970421

# Submission time Handle Problem Language Result Execution time Memory
970421 2024-04-26T13:52:43 Z 12345678 CONSUL (info1cup19_consul) C++17
100 / 100
29 ms 856 KB
#include "grader.h"
#include <bits/stdc++.h>

using namespace std;

mt19937 rng(time(0));

void solve(int n)
{
    vector<pair<int, int>> v;
    map<int, int> mp;
    for (int i=1; i<=n; i++) v.push_back({rng(), i});
    sort(v.begin(), v.end());
    for (int i=1; i<=min(n-3, 57); i++) mp[kth(v[i-1].second)]++;
    priority_queue<pair<int, int>> pq;
    for (auto [x, y]:mp) pq.push({y, x});
    if (!pq.empty()&&cnt(pq.top().second)>(n/3)) return say_answer(pq.top().second),void();
    if (!pq.empty()) pq.pop();
    if (!pq.empty()&&cnt(pq.top().second)>(n/3)) return say_answer(pq.top().second),void();
    if (!pq.empty()) pq.pop();
    if (!pq.empty()&&cnt(pq.top().second)>(n/3)) return say_answer(pq.top().second),void();
    if (!pq.empty()) pq.pop();
    say_answer(-1);
}
# Verdict Execution time Memory Grader output
1 Correct 20 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 344 KB Output is correct
2 Correct 26 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 448 KB Output is correct
2 Correct 26 ms 448 KB Output is correct
3 Correct 26 ms 452 KB Output is correct
4 Correct 25 ms 456 KB Output is correct
5 Correct 29 ms 856 KB Output is correct
6 Correct 27 ms 708 KB Output is correct
7 Correct 26 ms 708 KB Output is correct
8 Correct 27 ms 460 KB Output is correct
9 Correct 26 ms 452 KB Output is correct
10 Correct 27 ms 452 KB Output is correct
11 Correct 28 ms 708 KB Output is correct
12 Correct 28 ms 452 KB Output is correct
13 Correct 27 ms 452 KB Output is correct
14 Correct 27 ms 708 KB Output is correct