제출 #650622

#제출 시각아이디문제언어결과실행 시간메모리
650622birthdaycake선물상자 (IOI15_boxes)C++17
0 / 100
1 ms300 KiB
#include<bits/stdc++.h> #include "boxes.h" using namespace std; long long delivery(int n, int k, int l, int p[]) { int ans = INT_MAX; for(int i = 0; i < n; i++){ int cur = 0, items = k, cost = 0, dist; for(int j = 0; j <= i; j++){ if(items == 0){ items = k; cost += dist; cur = 0; dist = 0; } cost += (p[j] - cur); dist += (p[j] - cur); cur = p[j]; items--; } cost += dist; items = k; cur = 0; dist = 0; for(int j = n - 1; j > i; j--){ int nw = l - p[j] + 1; if(items == 0){ items = k; cost += dist; cur = 0; dist = 0; } cost += (nw - cur); dist += (nw- cur); cur = nw; items--; } ans = min(ans, cost); } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:14:22: warning: 'dist' may be used uninitialized in this function [-Wmaybe-uninitialized]
   14 |                 cost += dist;
      |                 ~~~~~^~~~~~~
#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...