Submission #364122

# Submission time Handle Problem Language Result Execution time Memory
364122 2021-02-08T09:18:14 Z soba CONSUL (info1cup19_consul) C++14
35 / 100
137 ms 364 KB
#include <bits/stdc++.h>
#include "grader.h"
//#include "grader.cpp"
using namespace std;
void solve(int n)
{
    int need=(n)/3;
    need++;
    vector<int>v;
    for(int i=1; i <= n ; i++)
    {
        v.push_back(i);
    }
    random_shuffle(v.begin(), v.end());
    random_shuffle(v.begin(), v.end());
    random_shuffle(v.begin(), v.end());
    int cn=1 , ans=-1;
    map<int,int>mp;
    for(int i = 1 ; i<=need ; i++)
    {
        int x=kth(v[i]);
        if(mp[x])
            continue;
        else mp[x]=cnt(x);
        if(mp[x]>=need)
        {
            ans=x;
            break;
        }
    }
    say_answer(ans);
}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:17:9: warning: unused variable 'cn' [-Wunused-variable]
   17 |     int cn=1 , ans=-1;
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 137 ms 364 KB Output is partially correct
2 Halted 0 ms 0 KB -