제출 #116646

#제출 시각아이디문제언어결과실행 시간메모리
116646roseanne_pcy선물상자 (IOI15_boxes)C++14
100 / 100
709 ms249988 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] = 2*a[i]; for(int i = n; i> n-k; i--) dp2[i] = 2*(l-a[i]); for(int i = k+1; i<= n; i++) dp1[i] = 2*a[i]+dp1[i-k]; for(int i = n-k; i>= 1; i--) dp2[i] = 2*(l-a[i])+dp2[i+k]; ll best = 1e18; for(int i = 0; i<= n; i++) { best = min(best, dp1[i]+dp2[i+1]); } //printf("%lld\n", best); 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; }
#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...