Submission #530146

#TimeUsernameProblemLanguageResultExecution timeMemory
530146LucaDantasCONSUL (info1cup19_consul)C++17
0 / 100
3078 ms1088 KiB
#include "grader.h" #include <bits/stdc++.h> using namespace std; constexpr int maxn = 1e5+10, SZ = 50, tot = 100; mt19937 rng(random_device{}()); int rnd(int x) { return (rng() % x + x) % x; } int a[maxn], mark[maxn]; void solve(int n) { vector<int> usar; map<int,int> freq; memset(a, 0, sizeof a); memset(mark, 0, sizeof mark); while(usar.size() < min(n, SZ)) { int rd = rnd(n)+1; if(!mark[rd]) a[rd] = kth(rd), freq[a[rd]]++; mark[rd] = 1; } vector<pair<int,int>> maiores; for(auto it : freq) maiores.push_back({it.second, it.first}); sort(maiores.begin(), maiores.end(), greater<pair<int,int>>()); while(maiores.size() > tot - SZ) maiores.pop_back(); if(n <= SZ) { if(maiores[0].first > n/3) say_answer(maiores[0].second); else say_answer(-1); return; } for(int i = 0; i < maiores.size(); i++) if(cnt(maiores[i].second) > n/3) return (void)(say_answer(maiores[i].first)); say_answer(-1); }

Compilation message (stderr)

consul.cpp: In function 'void solve(int)':
consul.cpp:19:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   19 |  while(usar.size() < min(n, SZ)) {
      |        ~~~~~~~~~~~~^~~~~~~~~~~~
consul.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for(int i = 0; i < maiores.size(); i++)
      |                 ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...