Submission #1084932

#TimeUsernameProblemLanguageResultExecution timeMemory
1084932yeediotBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
555 ms330724 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; #define pb push_back long long delivery(int n, int k, int l, int p[]){ vector<int>pos; for(int i = 0; i < n; i++){ pos.pb(p[i]); } long long ans = 8e18; if(k == n){ ans = l; } vector<long long>ldp(n + 10), rdp(n + 10); for(int i = 1; i <= n; i++){ ldp[i] = ldp[max(i - k, 0)] + pos[i - 1] * 2; } for(int i = n; i >= 1; i--){ rdp[i] = rdp[min(i + k, n + 1)] + (l - pos[i - 1]) * 2; } for(int i = 0; i <= n; i++){ ans = min(ans, ldp[i] + rdp[i + 1]); if(i + k + 1 < n + 10) ans = min(ans, ldp[i] + rdp[i + k + 1] + l); } return ans; }
#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...