제출 #596596

#제출 시각아이디문제언어결과실행 시간메모리
596596PiejanVDC선물상자 (IOI15_boxes)C++17
10 / 100
1 ms304 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int n, int k, int L, int positions[]) { vector<long long>l(n+1),r(n+1); l[0] = r[0] = 0; for(int i = 1 ; i <= n ; i++) { int p = max(0, i - k); l[i] = l[p] + (long long)2*(positions[i-1]); r[i] = r[p] + (long long)2*(L - positions[n - i]); //cout << l[i] << ' ' << r[i] << '\n'; } long long ans = (long long)1e18; for(int i = 0 ; i <= n ; i++) { ans = min(ans, l[i] + r[n-i]); ans = min(ans, l[i] + r[min(n, n-i + k)] + L); //cout << i << ' ' << ans << '\n'; } 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...