제출 #218687

#제출 시각아이디문제언어결과실행 시간메모리
218687alexandra_udristoiu선물상자 (IOI15_boxes)C++14
0 / 100
5 ms384 KiB
#include<iostream> #include "boxes.h" using namespace std; static long long d[10000005]; long long delivery(int n, int k, int lg, int p[]) { int i, u; long long sol; for(i = 1; i <= n; i++){ if(p[i] > lg - p[i]){ u = i - 1; break; } if(i <= k){ d[i] = 2 * p[i]; } else{ d[i] = 2 * p[i] + d[i - k]; } } for(i = n; i > u; i--){ if(i + k > n){ d[i] = 2 * (lg - p[i]); } else{ d[i] = 2 * (lg - p[i]) + d[i + k]; } } sol = d[u] + d[u + 1]; for(i = u; i >= 1 && i > u - k; i--){ sol = min(sol, lg + d[i - 1] + d[ min(i + k, n + 1) ]); } return sol; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:6:12: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int i, u;
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...