답안 #246735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246735 2020-07-10T04:29:07 Z SomeoneUnknown CONSUL (info1cup19_consul) C++14
15 / 100
60 ms 512 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
typedef pair<int, int> ii;

ii mii(int a, int b){
    return make_pair(a,b);
}
void solve(int n)
{
    /// insert your code
    /// for example
    int polls = 54;
    int fchecks = 6;
    vector<int> surveyres;
    if(n <= 60){
        for(int i = 1; i <= n; i++){
            surveyres.push_back(kth(i));
        }
        sort(surveyres.begin(), surveyres.end());
        int prv = 0;
        int amt = 0;
        for(int i = 0; i < n; i++){
            if(prv != surveyres[i]){
                prv = surveyres[i];
                amt = 0;
            }
            ++amt;
            if(amt * 3 > n){
                say_answer(prv);
                return;
            }
        }
        say_answer(-1);
        return;
    }
    priority_queue<ii> best;
    srand(time(0));
    bool touse[n+1];
    for(int i = 0; i <= n; ++i){
        touse[i] = false;
    }
    for(int i = 0; i < polls; i++){
        int x = rand();
        while(touse[x]){
            x = rand();
        }
        touse[x] = true;
    }
    for(int i = 0; i <= n; ++i){
        if(touse[i]){
            surveyres.push_back(kth(i));
        }
    }
    sort(surveyres.begin(), surveyres.end());
    best.push(mii(0,0));
    best.push(mii(0,0));
    best.push(mii(0,0));
    best.push(mii(0,0));
    int prv = 0;
    int amt = 0;
    for(int i = 0; i < n; i++){
        if(prv != surveyres[i]){
            best.push(mii(amt, prv));
            prv = surveyres[i];
            amt = 0;
        }
        ++amt;
    }
    best.push(mii(amt,prv));
    for(int i = 0; i < fchecks; i++){
        ii chkng = best.top();
        best.pop();
        if(cnt(chkng.second) * 3 > n){
            say_answer(chkng.second);
            return;
        }
    }
    say_answer(-1);
    return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -