제출 #742793

#제출 시각아이디문제언어결과실행 시간메모리
742793Abrar_Al_Samit선물상자 (IOI15_boxes)C++17
10 / 100
1 ms316 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; const int nax = 1e7 + 3; const long long INF = 1e18; long long other_wing[nax]; int n, k, L; long long ans = INF; long long delivery(int N, int K, int l, int p[]) { n = N, k = K, L = l; int cur = 0; int cnt = k; long long _time = p[0]; while(cur<n) { --cnt; other_wing[cur] = _time; if(cur+1<n) { if(cnt==0) { _time += p[cur] * 2; cnt = k; } _time += p[cur+1] - p[cur]; } ++cur; } ans = min(ans, _time+min(p[n-1], L-p[n-1])); cur = n-1; cnt = k; _time = L-p[n-1]; while(cur>=0) { --cnt; if(cur==0) { ans = min(ans, _time+min(p[0], L-p[0])); } if(cnt==0 && cur) { ans = min(ans, _time + min(p[cur], L-p[cur]) + other_wing[cur-1] + min(p[cur-1], L-p[cur-1])); } if(cur-1>=0) { if(cnt==0) { _time += 2 * min(p[cur], L-p[cur]); cnt = k; } _time += p[cur] - p[cur-1]; } --cur; } 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...