Submission #996457

#TimeUsernameProblemLanguageResultExecution timeMemory
996457fryingducBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms348 KiB
#include "bits/stdc++.h"
#include "boxes.h"
using namespace std;
const int maxn = 1e7 + 7;
long long fcw[maxn], fccw[maxn];
long long delivery(int n, int k, int l, int pos[]) {
    for(int i = 1; i <= n; ++i) {
        fcw[i] = fcw[max(0, i - k)] + pos[i] + min(pos[i], l - pos[i]); 
    }
    for(int i = n; i; --i) {
        fccw[i] = fccw[min(n + 1, i + k)] + (l - pos[i]) + min(pos[i], l - pos[i]);
    }
    
    long long ans = min(fcw[n], fccw[0]);;
    for(int i = 0; i <= n; ++i) {
        ans = min(ans, fcw[i] + fccw[i + 1]);
    }
    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...