제출 #557591

#제출 시각아이디문제언어결과실행 시간메모리
557591Ai7081선물상자 (IOI15_boxes)C++17
100 / 100
524 ms293772 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e7+5; const ll inf = 1e18; ll dp1[N], dp2[N], ans=inf; ll delivery(int n, int k, int L, int pos[]) { for (int i=0; i<n; i++) dp1[i] = (ll)pos[i] + (i>=k ? dp1[i-k] : 0) + (ll)min(pos[i], L-pos[i]); for (int i=n-1; i>=0; i--) dp2[i] = (ll)(L-pos[i]) + (i+k<n ? dp2[i+k] : 0) + (ll)min(pos[i], L-pos[i]); for (int i=0; i<n-1; i++) ans = min(ans, dp1[i] + dp2[i+1]); ans = min(ans, min(dp1[n-1], dp2[0])); 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...