답안 #255276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255276 2020-07-31T17:00:46 Z Osama_Alkhodairy 코알라 (APIO17_koala) C++17
56 / 100
108 ms 504 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 = 8;
    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 5 ms 384 KB Output is correct
4 Correct 5 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 Partially correct 95 ms 384 KB Output is partially correct
2 Partially correct 108 ms 384 KB Output is partially correct
3 Partially correct 89 ms 504 KB Output is partially correct
4 Partially correct 89 ms 384 KB Output is partially correct
5 Partially correct 88 ms 384 KB Output is partially correct
6 Partially correct 88 ms 384 KB Output is partially correct
7 Partially correct 87 ms 384 KB Output is partially correct
8 Partially correct 90 ms 384 KB Output is partially correct
9 Partially correct 86 ms 384 KB Output is partially correct
10 Partially correct 85 ms 384 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 33 ms 384 KB Output is partially correct
2 Partially correct 49 ms 384 KB Output is partially correct
3 Partially correct 48 ms 384 KB Output is partially correct
4 Partially correct 46 ms 384 KB Output is partially correct
5 Partially correct 48 ms 384 KB Output is partially correct
6 Partially correct 47 ms 376 KB Output is partially correct
7 Partially correct 46 ms 384 KB Output is partially correct
8 Partially correct 47 ms 384 KB Output is partially correct
9 Partially correct 47 ms 384 KB Output is partially correct
10 Partially correct 47 ms 504 KB Output is partially correct
11 Partially correct 51 ms 384 KB Output is partially correct
12 Partially correct 20 ms 384 KB Output is partially correct
13 Partially correct 45 ms 384 KB Output is partially correct
14 Partially correct 46 ms 384 KB Output is partially correct
15 Partially correct 48 ms 504 KB Output is partially correct
16 Partially correct 48 ms 384 KB Output is partially correct
17 Partially correct 49 ms 384 KB Output is partially correct
18 Partially correct 48 ms 384 KB Output is partially correct
19 Partially correct 47 ms 384 KB Output is partially correct
20 Partially correct 48 ms 384 KB Output is partially correct
21 Partially correct 47 ms 504 KB Output is partially correct
22 Partially correct 49 ms 384 KB Output is partially correct
23 Partially correct 41 ms 384 KB Output is partially correct
24 Partially correct 47 ms 384 KB Output is partially correct
25 Partially correct 47 ms 384 KB Output is partially correct
26 Partially correct 49 ms 384 KB Output is partially correct
27 Partially correct 48 ms 380 KB Output is partially correct
28 Partially correct 50 ms 376 KB Output is partially correct
29 Partially correct 47 ms 384 KB Output is partially correct
30 Partially correct 51 ms 384 KB Output is partially correct
31 Partially correct 48 ms 384 KB Output is partially correct
32 Partially correct 55 ms 384 KB Output is partially correct
33 Partially correct 51 ms 384 KB Output is partially correct
34 Partially correct 41 ms 384 KB Output is partially correct
35 Partially correct 49 ms 380 KB Output is partially correct
36 Partially correct 48 ms 384 KB Output is partially correct
37 Partially correct 42 ms 384 KB Output is partially correct
38 Partially correct 43 ms 384 KB Output is partially correct
39 Partially correct 42 ms 384 KB Output is partially correct
40 Partially correct 46 ms 384 KB Output is partially correct