제출 #32327

#제출 시각아이디문제언어결과실행 시간메모리
32327WhipppedCream선물상자 (IOI15_boxes)C++14
0 / 100
2 ms376 KiB
#ifdef atom #include "grader.cpp" #else #include "boxes.h" #endif #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vvi vector< vi > #define vii vector< ii > #define mp make_pair #define pb push_back const int maxn = 1e7+5; ll dp1[maxn]; ll dp2[maxn]; int a[maxn]; long long delivery(int n, int k, int l, int p[]) { for(int i = 1; i<= n; i++) a[i] = p[i-1]; for(int i = 1; i<= k; i++) dp1[i] = p[i]; for(int i = n; i> n-k; i--) dp2[i] = l-p[i]; for(int i = k+1; i<= n; i++) dp1[i] = p[i]+dp1[i-k]; for(int i = n-k; i>= 1; i--) dp2[i] = (l-p[i])+dp2[i+k]; ll best = 1e18; for(int i = 0; i<= n; i++) { best = min(best, dp1[i]+dp2[i+1]); } for(int i = 1; i<= n; i++) { ll left = dp1[i-1]; ll right = i+k<= n?dp2[i+k]:0; best = min(best, left+right+l); } return best; return 0; }
#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...