제출 #588358

#제출 시각아이디문제언어결과실행 시간메모리
588358sofapuden선물상자 (IOI15_boxes)C++14
20 / 100
1 ms272 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 ? min(p[i]-p[i-1],L-(p[i]-p[i-1])) : min(p[i],L-p[i]) + (i ? min(p[i-1],L-p[i-1]) : 0ll)); } for(int i = N; i; --i){ suf[i-1] = suf[i]+((N-i)%K ? min(p[i]-p[i-1],L-(p[i]-p[i-1])) : (i == N ? 0ll : min(p[i],L-p[i])) + min(p[i-1],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...