답안 #310154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310154 2020-10-06T01:02:17 Z aZvezda 선물상자 (IOI15_boxes) C++14
컴파일 오류
0 ms 0 KB
const int MAX_N = 1e7 + 10;
ll dp[MAX_N];
ll sufMin[MAX_N];

long long delivery(int N, int K, int L, int p[]) {
    bool gotMid = false;
    int lastSmaller = -1;
    int n = N, k = K;
    for(int i = 0; i < n; i ++) {
        if(p[i] == L / 2 && L % 2 == 0) {
            gotMid = true;
        }
        if(p[i] <= (L - 1) / 2) {
            lastSmaller = i;
        }
    }
    for(int i = 0; i < n; i ++) {
        if(i >= k - 1) {
            ll cost = mod * mod;
            if(i - k + 1 <= lastSmaller && lastSmaller < i) {
                cost = 2 * p[lastSmaller] + 2 * L - 2 * p[lastSmaller + 1];
            } else if(i - k + 1 <= lastSmaller && lastSmaller <= i) {
                cost = 2 * p[lastSmaller];
            } else if(i <= lastSmaller) {
                cost = 2 * p[i];
            } else {
                cost = 2 * L - 2 * p[i - k + 1];
            }
            dp[i] = dp[i - k + 1] + cost;
        }
        //cout << dp[i] << " ";
    }
    for(int i = n - 1; i > 0; i --) {
        if(i == n - 1) {
            sufMin[i] = dp[i];
        } else {
            sufMin[i] = min(dp[i] + 2 * L - 2 * p[i + 1], sufMin[i + 1]);
        }
    }
    ll ret = mod * mod;
    for(int i = 1; i <= k; i ++) {
        chkmin(ret, p[i - 1] * 2 + sufMin[n - i]);
    }
    return ret;
}

Compilation message

boxes.cpp:2:1: error: 'll' does not name a type
    2 | ll dp[MAX_N];
      | ^~
boxes.cpp:3:1: error: 'll' does not name a type
    3 | ll sufMin[MAX_N];
      | ^~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:13: error: 'll' was not declared in this scope
   19 |             ll cost = mod * mod;
      |             ^~
boxes.cpp:21:17: error: 'cost' was not declared in this scope
   21 |                 cost = 2 * p[lastSmaller] + 2 * L - 2 * p[lastSmaller + 1];
      |                 ^~~~
boxes.cpp:23:17: error: 'cost' was not declared in this scope
   23 |                 cost = 2 * p[lastSmaller];
      |                 ^~~~
boxes.cpp:25:17: error: 'cost' was not declared in this scope
   25 |                 cost = 2 * p[i];
      |                 ^~~~
boxes.cpp:27:17: error: 'cost' was not declared in this scope
   27 |                 cost = 2 * L - 2 * p[i - k + 1];
      |                 ^~~~
boxes.cpp:29:13: error: 'dp' was not declared in this scope; did you mean 'p'?
   29 |             dp[i] = dp[i - k + 1] + cost;
      |             ^~
      |             p
boxes.cpp:29:37: error: 'cost' was not declared in this scope
   29 |             dp[i] = dp[i - k + 1] + cost;
      |                                     ^~~~
boxes.cpp:35:13: error: 'sufMin' was not declared in this scope
   35 |             sufMin[i] = dp[i];
      |             ^~~~~~
boxes.cpp:35:25: error: 'dp' was not declared in this scope; did you mean 'p'?
   35 |             sufMin[i] = dp[i];
      |                         ^~
      |                         p
boxes.cpp:37:13: error: 'sufMin' was not declared in this scope
   37 |             sufMin[i] = min(dp[i] + 2 * L - 2 * p[i + 1], sufMin[i + 1]);
      |             ^~~~~~
boxes.cpp:37:29: error: 'dp' was not declared in this scope; did you mean 'p'?
   37 |             sufMin[i] = min(dp[i] + 2 * L - 2 * p[i + 1], sufMin[i + 1]);
      |                             ^~
      |                             p
boxes.cpp:37:25: error: 'min' was not declared in this scope
   37 |             sufMin[i] = min(dp[i] + 2 * L - 2 * p[i + 1], sufMin[i + 1]);
      |                         ^~~
boxes.cpp:40:5: error: 'll' was not declared in this scope
   40 |     ll ret = mod * mod;
      |     ^~
boxes.cpp:42:16: error: 'ret' was not declared in this scope
   42 |         chkmin(ret, p[i - 1] * 2 + sufMin[n - i]);
      |                ^~~
boxes.cpp:42:36: error: 'sufMin' was not declared in this scope
   42 |         chkmin(ret, p[i - 1] * 2 + sufMin[n - i]);
      |                                    ^~~~~~
boxes.cpp:42:9: error: 'chkmin' was not declared in this scope
   42 |         chkmin(ret, p[i - 1] * 2 + sufMin[n - i]);
      |         ^~~~~~
boxes.cpp:44:12: error: 'ret' was not declared in this scope
   44 |     return ret;
      |            ^~~