제출 #793550

#제출 시각아이디문제언어결과실행 시간메모리
793550UltraFalcon선물상자 (IOI15_boxes)C++17
10 / 100
1 ms212 KiB
// pragmas #ifndef DEBUG #endif #include <bits/stdc++.h> #include "boxes.h" // #define int long long using ll = long long; using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<ll> cost_pref(N, 0); for (int i=0; i<N; i++) { if (i>=K) cost_pref[i] = cost_pref[i-K]; cost_pref[i] += 2*p[i]; } vector<ll> cost_suff(N, 0); for (int i=N-1; i>=0; i--) { if (i+K < N) cost_suff[i] = cost_suff[i+K]; cost_suff[i] += 2*(L-p[i]); } // for (auto &x : cost_pref) { // cerr << x << " "; // } ll res = min(cost_pref[N-1], cost_suff[0]); for (int i=0; i<N; i++) { res = min(res, cost_pref[i]+(ll)L+cost_suff[min(N-1, i+K)]); res = min(res, cost_pref[i]+cost_suff[min(N-1, i+1)]); } return res; }
#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...