Submission #588366

#TimeUsernameProblemLanguageResultExecution timeMemory
588366sofapudenBoxes with souvenirs (IOI15_boxes)C++14
20 / 100
1 ms212 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; ll delivery(int N, int K, int L, int p[]) { vector<ll> pre(N+1), suf(N+1); pre[0] = 0; suf[N] = 0; for(int i = 0; i < N; ++i){ pre[i+1] = pre[i]+(i%K ? p[i]-p[i-1] : p[i] + (i ? p[i-1] : 0ll)); } for(int i = N; i; --i){ suf[i-1] = suf[i]+((N-i)%K ? p[i]-p[i-1] : (i == N ? 0ll : L-p[i]) + L-p[i-1]); } ll ans = (1ll<<60); for(int i = 0; i <= N; ++i){ ans = min(ans,pre[i]+suf[i]+(i ? min(p[i-1],L-p[i-1]) : 0) + (i == N ? 0 : min(p[i],L-p[i]))); } 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...