제출 #933797

#제출 시각아이디문제언어결과실행 시간메모리
933797raul2008487선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "boxes.h" #define ll int #define in insert #define pb push_back #define vl vector<ll> #define fi first #define se second #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const ll inf = 1000000000000000000; long long delivery(int N, int K, int L, int p[]) { ll n = N, k = K, ans = inf; vl dpp(n + 2), dps(n + 2); dpp[0] = dps[n + 1] = 0; for(i = 1; i <= n; i++){ ll pr = max(i - k, 0); dpp[i] = dpp[pr] + p[i - 1] + min(L - p[i - 1], p[i - 1]); } for(i = n; i > 0; i--){ ll nxt = min(i + k, n + 1); dps[i] = dps[nxt] + (L - p[i - 1]) + min(L - p[i - 1], p[i - 1]); } for(i = 0; i <= n; i++){ ans = min(ans, (dpp[i] + dps[i + 1])); } return ans; }

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

boxes.cpp:12:16: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   12 | const ll inf = 1000000000000000000;
      |                ^~~~~~~~~~~~~~~~~~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:9: error: 'i' was not declared in this scope
   17 |     for(i = 1; i <= n; i++){
      |         ^
boxes.cpp:21:9: error: 'i' was not declared in this scope
   21 |     for(i = n; i > 0; i--){
      |         ^
boxes.cpp:25:9: error: 'i' was not declared in this scope
   25 |     for(i = 0; i <= n; i++){
      |         ^