제출 #1120929

#제출 시각아이디문제언어결과실행 시간메모리
1120929SalihSahin선물상자 (IOI15_boxes)C++14
10 / 100
3 ms336 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; #include "boxes.h" const long long inf = 1e18; long long delivery(int N, int K, int L, int p[]) { vector<long long> pos(N); for(int i = 0; i < N; i++){ pos[i] = p[i]; } vector<long long> dpl(N+1), dpr(N+1); for(int i = 1; i <= N; i++){ if(i < K) dpl[i] = pos[i-1] * 2; else dpl[i] = dpl[i - K] + pos[i-1] * 2; } for(int i = 1; i <= N; i++){ if(i < K) dpr[i] = (L - pos[N-i]) * 2; else dpr[i] = dpr[i - K] + (L - pos[N-i]) * 2; } /* for(int i = 1; i <= N; i++){ cout<<dpl[i]<<" "; } cout<<endl; for(int i = 1; i <= N; i++){ cout<<dpr[i]<<" "; } cout<<endl; */ long long ans = inf; for(int l = 0; l <= N; l++){ for(int r = 0; r <= N; r++){ if(l + r > N) break; int rem = N - l - r; long long calc = dpl[l] + dpr[r] + ((rem + K - 1)/K) * L; ans = min(ans, calc); } } 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...