제출 #500890

#제출 시각아이디문제언어결과실행 시간메모리
500890aymanrs선물상자 (IOI15_boxes)C++14
100 / 100
542 ms292312 KiB
#include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int positions[]){ long long ans = LONG_LONG_MAX; long long w[N], c[N]; for(int j = 0;j < N;j++){ if(j < K) w[j] = min(positions[j], L - positions[j]) + positions[j]; else w[j] = min(positions[j], L - positions[j]) + w[j-K] + positions[j]; } for(int j = N-1;j >= 0;j--){ if(j + K >= N) c[j] = min(positions[j], L - positions[j]) + L - positions[j]; else c[j] = min(positions[j], L - positions[j]) + c[j+K] + L - positions[j]; } for(int i = -1;i < N;i++){ if(i == -1) ans = min(ans, c[0]); else if (i == N - 1) ans = min(ans, w[N-1]); else ans = min(ans, w[i] + c[i+1]); } return ans; } //int main(){ // int p[] = {1, 9, 11, 19}; // cout << delivery(4, 2, 20, p) << '\n'; //}
#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...