제출 #854419

#제출 시각아이디문제언어결과실행 시간메모리
854419KN200711선물상자 (IOI15_boxes)C++14
100 / 100
768 ms458708 KiB
#include "boxes.h" # include <bits/stdc++.h> # define ll long long using namespace std; const int MXN = 1e7; ll sm[MXN]; ll delivery(int N, int K, int L, int p[]) { vector<ll> pp; pp.clear(); for(int i=0;i<N;i++) pp.push_back(p[i]); sort(pp.begin(), pp.end()); vector<ll> pref(N), suff(N + 1); for(int i=0;i<K;i++) sm[i] = 0ll; for(int i=0;i<N;i++) { sm[i%K] += 2ll * pp[i]; pref[i] = sm[i%K]; } for(int i=0;i<K;i++) sm[i] = 0ll; for(int i=N-1;i>=0;i--) { sm[i%K] += 2ll * L - 2ll * pp[i]; suff[i] = sm[i%K]; } suff[N] = 0ll; vector<ll> solve(N); for(int i=0;i<N;i++) { solve[i] = pref[i]; if(i == K-1) solve[i] = min(solve[i], 1ll * L); else if(i > K) solve[i] = min(solve[i], solve[i - K] + 1ll * L); } ll ans = suff[0]; for(int i=0;i<N;i++) { ans = min(ans, solve[i] + suff[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...