Submission #970420

# Submission time Handle Problem Language Result Execution time Memory
970420 2024-04-26T13:51:43 Z 12345678 CONSUL (info1cup19_consul) C++17
85 / 100
29 ms 712 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, 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 Incorrect 20 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 344 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 456 KB Output is correct
2 Correct 28 ms 452 KB Output is correct
3 Correct 25 ms 448 KB Output is correct
4 Correct 26 ms 452 KB Output is correct
5 Correct 26 ms 708 KB Output is correct
6 Correct 26 ms 452 KB Output is correct
7 Correct 27 ms 456 KB Output is correct
8 Correct 27 ms 460 KB Output is correct
9 Correct 27 ms 704 KB Output is correct
10 Correct 29 ms 452 KB Output is correct
11 Correct 26 ms 456 KB Output is correct
12 Correct 26 ms 712 KB Output is correct
13 Correct 27 ms 456 KB Output is correct
14 Correct 27 ms 452 KB Output is correct