답안 #808730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
808730 2023-08-05T10:08:49 Z someone 코알라 (APIO17_koala) C++14
63 / 100
10 ms 384 KB
#include "koala.h"
#include <bits/stdc++.h>
using namespace std;

const int MAX = 1e2 + 42, INF = 1e3 + 42;

int n, w, perm[MAX];

int minValue(int N, int W) {
    // TODO: Implement Subtask 1 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    return 0;
}

int maxValue(int N, int W) {
    // TODO: Implement Subtask 2 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    return 0;
}

int greaterValue(int N, int W) {
    // TODO: Implement Subtask 3 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    return 0;
}

int simulate(int cost, deque<int> other, deque<int> act) {
    int stone = w, sum = 0, nb = 0;
    while((stone % cost) != 0 && other[0] != 0) {
        stone--;
        other.pop_front();
    }
    for(int i = 0; i < cost && other[i]; i++)
        sum += other[i];
    while(stone >= cost && (act[0] != 0 || other[0] != 0)) {
        if(sum < act[0]) {
            nb++;
            stone -= cost;
            act.pop_front();
        } else {
            sum = 0;
            for(int i = 0; i < cost && other[0]; i++) {
                stone--;
                other.pop_front();
            }
            for(int i = 0; i < cost && other[i]; i++)
                sum += other[i];
        }
    }
    return nb;
}

void DPR(int left, int right, vector<int> pos) {
    if(pos.empty()) return;
    if(left == right) {
        perm[pos[0]] = left;
        return;
    }
    deque<int> other, act;
    act.push_back(0);
    other.push_back(0);
    for(int i = 1; i <= n; i++) {
        if(i < left || i > right)
            other.push_front(i);
        else
            act.push_front(i);
    }
    int sz = (int)pos.size(), nb = 0, best = INF;
    for(int i = 1; i * sz <= w; i++) {
        int chosen = simulate(i+1, other, act);
        if(abs(sz - 2 * chosen) < best) {
            nb = i;
            best = abs(sz - 2 * chosen);
        }
        if(chosen == 0)
            i = w + 1;
    }
    int B[n], R[n];
    for(int i = 0; i < n; i++)
        B[i] = R[i] = 0;
    for(int p : pos)
        B[p] = nb;
    playRound(B, R);
    vector<int> posInf, posSup;
    for(int p : pos)
        if(R[p] >= nb+1)
            posSup.push_back(p);
        else
            posInf.push_back(p);
    DPR(left, left - 1 + (int)posInf.size(), posInf);
    DPR(left + (int)posInf.size(), right, posSup);
}

void allValues(int N, int W, int *P) {
    n = N, w = W;
    vector<int> vals, pos;
    for(int i = 0; i < n; i++)
        pos.push_back(i);
    for(int i = 0; i < n; i++)
        vals.push_back(i+1);
    DPR(1, N, pos);
    for(int i = 0; i < n; i++)
        P[i] = perm[i];
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 336 KB Output is correct
2 Correct 8 ms 336 KB Output is correct
3 Correct 10 ms 336 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
5 Correct 8 ms 336 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 8 ms 336 KB Output is correct
10 Correct 9 ms 336 KB Output is correct
11 Correct 9 ms 356 KB Output is correct
12 Correct 10 ms 336 KB Output is correct
13 Correct 9 ms 336 KB Output is correct
14 Correct 8 ms 340 KB Output is correct
15 Correct 8 ms 336 KB Output is correct
16 Correct 8 ms 336 KB Output is correct
17 Correct 8 ms 336 KB Output is correct
18 Correct 8 ms 344 KB Output is correct
19 Correct 8 ms 336 KB Output is correct
20 Correct 8 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 3 ms 368 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 3 ms 336 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 3 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 3 ms 336 KB Output is correct
17 Correct 3 ms 336 KB Output is correct
18 Correct 3 ms 336 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 3 ms 336 KB Output is correct
26 Correct 3 ms 336 KB Output is correct
27 Correct 3 ms 336 KB Output is correct
28 Correct 3 ms 336 KB Output is correct
29 Correct 3 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 3 ms 336 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 3 ms 336 KB Output is correct
34 Correct 3 ms 336 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 3 ms 336 KB Output is correct
37 Correct 3 ms 336 KB Output is correct
38 Correct 3 ms 348 KB Output is correct
39 Correct 3 ms 336 KB Output is correct
40 Correct 3 ms 336 KB Output is correct