Submission #922000

# Submission time Handle Problem Language Result Execution time Memory
922000 2024-02-04T16:20:00 Z Ianis CONSUL (info1cup19_consul) C++17
100 / 100
25 ms 428 KB
#include <vector>
#include <algorithm>
#include <map>
#include <random>
#include <chrono>
#include "grader.h"

using namespace std;

#define fi first
#define se second

#define all(a) (a).begin(), (a).end()

using pii = pair<int, int>;

void solve(int n) {
   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

   map<int, bool> vis;
   map<int, int> mp;

   for (int i = 1; i <= 55 && i <= n; i++) {
      int pos = abs(int(rng())) % n + 1;
      if (!vis[pos]) {
         vis[pos] = true;
         mp[kth(pos)]++;
      }
   }

   vector<pii> v;
   for (auto [ val, fr ] : mp)
      v.push_back({ -fr, val });
   sort(all(v));

   for (int i = 0; i < 5 && i < int(v.size()); i++) {
      if (cnt(v[i].se) > n / 3) {
         say_answer(v[i].se);
         return;
      }
   }

   say_answer(-1);
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 424 KB Output is correct
2 Correct 21 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 424 KB Output is correct
2 Correct 22 ms 424 KB Output is correct
3 Correct 21 ms 424 KB Output is correct
4 Correct 20 ms 428 KB Output is correct
5 Correct 22 ms 428 KB Output is correct
6 Correct 25 ms 424 KB Output is correct
7 Correct 22 ms 424 KB Output is correct
8 Correct 25 ms 424 KB Output is correct
9 Correct 24 ms 424 KB Output is correct
10 Correct 23 ms 424 KB Output is correct
11 Correct 24 ms 424 KB Output is correct
12 Correct 24 ms 424 KB Output is correct
13 Correct 23 ms 428 KB Output is correct
14 Correct 24 ms 428 KB Output is correct