답안 #799852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799852 2023-08-01T06:36:49 Z n3rm1n CONSUL (info1cup19_consul) C++17
100 / 100
34 ms 308 KB
#include<bits/stdc++.h>
#include "grader.h"
#define endl '\n'
using namespace std;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void solve(int N)
{
    map < int, int > checked;
    int atleast = N/3 + 1;
    vector < int > index;
    for (int i = 1; i <= N; ++ i)
        index.push_back(i);
    random_shuffle(index.begin(), index.end());
    vector < int > g;
    for (int i = 0; i < min(N, 30); ++ i)
    {
        //cout << index[i] << endl;
        int x = kth(index[i]);

        if(checked[x])continue;
        else
        { g.push_back(x);
        }
        checked[x] = 1;
    }
    for (int i = 0; i < g.size(); ++ i)
    {
        if(cnt(g[i]) >= atleast)
        {
            say_answer(g[i]);
            return;
        }
    }
    say_answer(-1);
}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < g.size(); ++ i)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 208 KB Output is correct
2 Correct 27 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 208 KB Output is correct
2 Correct 29 ms 208 KB Output is correct
3 Correct 31 ms 308 KB Output is correct
4 Correct 23 ms 256 KB Output is correct
5 Correct 26 ms 296 KB Output is correct
6 Correct 19 ms 208 KB Output is correct
7 Correct 34 ms 208 KB Output is correct
8 Correct 31 ms 208 KB Output is correct
9 Correct 21 ms 208 KB Output is correct
10 Correct 23 ms 208 KB Output is correct
11 Correct 29 ms 208 KB Output is correct
12 Correct 30 ms 308 KB Output is correct
13 Correct 33 ms 288 KB Output is correct
14 Correct 28 ms 208 KB Output is correct