Submission #588385

#TimeUsernameProblemLanguageResultExecution timeMemory
588385sofapudenBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
622 ms278904 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); vector<ll> presu(K,0), sufsu(K,0); pre[0] = 0; suf[N] = 0; for(int i = 0; i < N; ++i){ pre[i+1] = p[i] + presu[i%K]; presu[i%K]+=2*p[i]; } for(int i = N; i; --i){ suf[i-1] = L-p[i-1] + sufsu[(N-i)%K]; sufsu[(N-i)%K] += 2*(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...