제출 #769874

#제출 시각아이디문제언어결과실행 시간메모리
769874teokakabadze선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
long long delivery(int N, int K, int L, int p[]) { n = N, k = K; for(i = 0; i < n; i++) a[i] = p[i]; sort(a, a + n); d.pb({0, -1}); for(i = 0; i < n; i++) { if(d.front().s == i - k - 1) d.pop_front(); dp[i] = 2 * a[i] + d.front().f; while(d.size() && d.front().f >= dp[i]) d.pop_front(); d.pb({dp[i], i}); } while(d.size()) d.pop_back(); d.pb({0, n}); for(i = n - 1; i >= 0; i--) { if(d.front().s == i + k + 1) d.pop_front(); dp1[i] = 2 * (L - a[i]) + d.front().f; while(d.size() && d.front().f >= dp1[i]) d.pop_front(); d.pb({dp1[i], i}); } ans = 1e18; for(i = 0; i < n; i++) ans = min(ans, dp[i] + dp1[(i + 1) % n]); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:3:5: error: 'n' was not declared in this scope
    3 |     n = N, k = K;
      |     ^
boxes.cpp:3:12: error: 'k' was not declared in this scope
    3 |     n = N, k = K;
      |            ^
boxes.cpp:4:9: error: 'i' was not declared in this scope
    4 |     for(i = 0; i < n; i++)
      |         ^
boxes.cpp:5:5: error: 'a' was not declared in this scope
    5 |     a[i] = p[i];
      |     ^
boxes.cpp:6:10: error: 'a' was not declared in this scope
    6 |     sort(a, a + n);
      |          ^
boxes.cpp:6:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    6 |     sort(a, a + n);
      |     ^~~~
      |     short
boxes.cpp:7:5: error: 'd' was not declared in this scope
    7 |     d.pb({0, -1});
      |     ^
boxes.cpp:8:9: error: 'i' was not declared in this scope
    8 |     for(i = 0; i < n; i++)
      |         ^
boxes.cpp:11:9: error: 'dp' was not declared in this scope; did you mean 'p'?
   11 |         dp[i] = 2 * a[i] + d.front().f;
      |         ^~
      |         p
boxes.cpp:17:9: error: 'i' was not declared in this scope
   17 |     for(i = n - 1; i >= 0; i--)
      |         ^
boxes.cpp:20:9: error: 'dp1' was not declared in this scope
   20 |         dp1[i] = 2 * (L - a[i]) + d.front().f;
      |         ^~~
boxes.cpp:24:5: error: 'ans' was not declared in this scope
   24 |     ans = 1e18;
      |     ^~~
boxes.cpp:25:9: error: 'i' was not declared in this scope
   25 |     for(i = 0; i < n; i++)
      |         ^
boxes.cpp:26:20: error: 'dp' was not declared in this scope; did you mean 'p'?
   26 |     ans = min(ans, dp[i] + dp1[(i + 1) % n]);
      |                    ^~
      |                    p
boxes.cpp:26:28: error: 'dp1' was not declared in this scope
   26 |     ans = min(ans, dp[i] + dp1[(i + 1) % n]);
      |                            ^~~
boxes.cpp:26:11: error: 'min' was not declared in this scope
   26 |     ans = min(ans, dp[i] + dp1[(i + 1) % n]);
      |           ^~~