답안 #255266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255266 2020-07-31T16:48:10 Z Osama_Alkhodairy 코알라 (APIO17_koala) C++17
63 / 100
86 ms 512 KB
#include <bits/stdc++.h>
#include "koala.h"
//~ #include "grader.cpp"
using namespace std;

int n;

bool cmp(int i, int j){
    int B[n], R[n];
    for(int i = 0 ; i < n ; i++){
        B[i] = R[i] = 0;
    }
    int l = 1, r = 9;
    while(l <= r){
        int mid = (l + r) / 2;
        B[i] = B[j] = mid;
        playRound(B, R);
        if((R[i] > B[i]) == (R[j] > B[j])){
            if(R[i] > B[j]) l = mid + 1;
            else r = mid - 1;
        }
        else return R[j] > B[j];
    }
    assert(false);
}
int minValue(int N, int W) {
    n = N;
    int B[n], R[n];
    for(int i = 0 ; i < n ; i++){
        B[i] = R[i] = 0;
    }
    B[0]++;
    playRound(B, R);
    for(int i = 0 ; i < n ; i++){
        if(B[i] >= R[i]) return i;
    }
    return 0;
}

int maxValue(int N, int W) {
    n = N;
    int B[n], R[n];
    vector <int> cands;
    for(int i = 0 ; i < n ; i++){
        cands.push_back(i);
    }
    while(cands.size() > 1){
        for(int i = 0 ; i < n ; i++){
            B[i] = R[i] = 0;
        }
        int cur = W / cands.size();
        for(auto &i : cands) B[i] = cur;
        playRound(B, R);
        cands.clear();
        for(int i = 0 ; i < n ; i++){
            if(B[i] == cur && R[i] > B[i]){
                cands.push_back(i);
            }
        }
    }
    return cands[0];
}

int greaterValue(int N, int W) {
    n = N;
    if(cmp(0, 1)) return 1;
    return 0;
}

void allValues(int N, int W, int *P) {
    n = N;
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        vector <int> all;
        for(int i = 0 ; i < n ; i++){
            all.push_back(i);
        }
        stable_sort(all.begin(), all.end(), cmp);
        for(int i = 0 ; i < n ; i++){
            P[all[i]] = i + 1;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 384 KB Output is correct
2 Correct 18 ms 384 KB Output is correct
3 Correct 18 ms 384 KB Output is correct
4 Correct 17 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 384 KB Output is correct
2 Correct 86 ms 384 KB Output is correct
3 Correct 73 ms 384 KB Output is correct
4 Correct 73 ms 384 KB Output is correct
5 Correct 74 ms 512 KB Output is correct
6 Correct 73 ms 384 KB Output is correct
7 Correct 74 ms 384 KB Output is correct
8 Correct 74 ms 384 KB Output is correct
9 Correct 74 ms 384 KB Output is correct
10 Correct 71 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 26 ms 384 KB Output is partially correct
2 Partially correct 39 ms 384 KB Output is partially correct
3 Partially correct 38 ms 384 KB Output is partially correct
4 Partially correct 37 ms 384 KB Output is partially correct
5 Partially correct 39 ms 504 KB Output is partially correct
6 Partially correct 38 ms 384 KB Output is partially correct
7 Partially correct 39 ms 376 KB Output is partially correct
8 Partially correct 37 ms 384 KB Output is partially correct
9 Partially correct 38 ms 384 KB Output is partially correct
10 Partially correct 37 ms 376 KB Output is partially correct
11 Partially correct 38 ms 384 KB Output is partially correct
12 Partially correct 16 ms 384 KB Output is partially correct
13 Partially correct 36 ms 384 KB Output is partially correct
14 Partially correct 37 ms 384 KB Output is partially correct
15 Partially correct 38 ms 384 KB Output is partially correct
16 Partially correct 38 ms 384 KB Output is partially correct
17 Partially correct 39 ms 384 KB Output is partially correct
18 Partially correct 37 ms 384 KB Output is partially correct
19 Partially correct 38 ms 384 KB Output is partially correct
20 Partially correct 36 ms 384 KB Output is partially correct
21 Partially correct 37 ms 384 KB Output is partially correct
22 Partially correct 40 ms 384 KB Output is partially correct
23 Partially correct 32 ms 384 KB Output is partially correct
24 Partially correct 37 ms 384 KB Output is partially correct
25 Partially correct 35 ms 384 KB Output is partially correct
26 Partially correct 38 ms 384 KB Output is partially correct
27 Partially correct 39 ms 384 KB Output is partially correct
28 Partially correct 39 ms 384 KB Output is partially correct
29 Partially correct 37 ms 384 KB Output is partially correct
30 Partially correct 37 ms 376 KB Output is partially correct
31 Partially correct 43 ms 376 KB Output is partially correct
32 Partially correct 39 ms 384 KB Output is partially correct
33 Partially correct 37 ms 384 KB Output is partially correct
34 Partially correct 32 ms 384 KB Output is partially correct
35 Partially correct 38 ms 504 KB Output is partially correct
36 Partially correct 35 ms 384 KB Output is partially correct
37 Partially correct 34 ms 380 KB Output is partially correct
38 Partially correct 40 ms 384 KB Output is partially correct
39 Partially correct 35 ms 384 KB Output is partially correct
40 Partially correct 38 ms 376 KB Output is partially correct