제출 #707404

#제출 시각아이디문제언어결과실행 시간메모리
707404tht2005선물상자 (IOI15_boxes)C++17
10 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; #define LL long long LL delivery(int N, int K, int L, int pos[]) { vector<LL> f(N); for(int i = 0; i < N; ++i) { f[i] = pos[i] + min(pos[i], L - pos[i]); if(i >= K) { f[i] += f[i - K]; } } vector<LL> g(N); for(int i = N - 1; i >= 0; --i) { g[i] = L - pos[i] + min(pos[i], L - pos[i]); if(i + K < N) { g[i] += g[i + K]; } } LL res = 1LL << 60; for(int i = 0; i < N; ++i) { res = min(res, f[i] + (i + 1 < N ? g[i + 1] : 0)); } return res; } #ifdef tomoshibi int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, k, l, pos[100]; cin >> n >> k >> l; for(int i = 0; i < n; ++i) { cin >> pos[i]; } cout << delivery(n, k, l, pos); return 0; } #endif
#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...