제출 #429134

#제출 시각아이디문제언어결과실행 시간메모리
429134dreezy선물상자 (IOI15_boxes)C++17
10 / 100
1 ms308 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define ll long long long long delivery(int N, int K, int L, int p[]) { //vector<ll> p(N); vector<ll> left(N); for(int i =0; i<N;i++) { left[i] = 2 * p[i]; if(i / K> 0) left[i] += left[i/K * K]; } vector<ll> right(N); for(int i =N - 1; i>=0;i--) { right[i] = 2 * (L - p[i] ); if((N - i - 1) / K> 0) right[i] += right[ N - (N- i - 1)/K * K]; } ll ans = min(left[N - 1], right[0]); for(int i = 1; i<N ; i++){ ll posans = left[i - 1] + right[i]; ans = min(ans, posans); } for(int i = 0; i<N ; i++){ ll posans = L; if(i > 0) posans +=left[i - 1]; if (i +K < N) posans +=right[i + K]; ans = min(ans, posans); } 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...