Submission #813140

#TimeUsernameProblemLanguageResultExecution timeMemory
813140KerimBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
0 ms212 KiB
#include "boxes.h" #include "bits/stdc++.h" using namespace std; #define ll long long int f(int n, int k){ return (n+k-1) / k; } long long delivery(int n, int k, int l, int p[]) { ll answer = f(n, k) * 1LL * l; vector<int> arr(n+2); for (int i = 1; i <= n; i++) arr[i] = p[i-1]; arr[n+1] = l; vector<ll> pref(n+2), suf(n+2); for (int i = 1; i <= n; i++){ pref[i] = arr[i]; if (i >= k) pref[i] += pref[i-k]; } for (int i = n; i >= 1; i--){ suf[i] = l - arr[i]; if (i + k <= n+1) suf[i] += suf[i+k]; } for (int i = 0; i <= n; i++){ answer = min(answer, 2*(pref[i] + suf[i+1])); if (i+k <= n+1) answer = min(answer, l + 2*(pref[i] + suf[i+k])); } return answer; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:13:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |     for (int i = 1; i <= n; i++)
      |     ^~~
boxes.cpp:15:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |   arr[n+1] = l;
      |   ^~~
#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...