제출 #387886

#제출 시각아이디문제언어결과실행 시간메모리
387886AmineTrabelsi선물상자 (IOI15_boxes)C++14
100 / 100
768 ms372164 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; const int M = 1e7+5; ll delivery(int N, int K, int L, int p[]) { vector<ll> l(N+1,0),r(N+1,0),cnt(N+1,0); for(int i=0;i<N;i++){ // prefix cnt[i%K] += p[i]*2; l[i] = cnt[i%K]; } cnt.assign(N+1,0); for(int i=N-1;i>=0;i--){ // suffix cnt[i%K] += 2*(L-p[i]); r[i] = cnt[i%K]; } ll ans = 1e18; for(int i=0;i<=N;i++){ // calc best answer ans = min(ans,(i ? l[i-1] : 0)+r[i]); } for(int i=0;i<=N-K;i++){ // best answer with a full circle turn (max 1) ans = min(ans,(i ? l[i-1] : 0)+r[i+K]+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...