제출 #429155

#제출 시각아이디문제언어결과실행 시간메모리
429155dreezy선물상자 (IOI15_boxes)C++17
100 / 100
593 ms219064 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]; //cout << "LEFT "<<p[i]<<": "<<left[i]<<endl; } vector<ll> right(N); for(int i =N - 1; i>=0;i--) { right[i] = 2 * (L - p[i] ); if(i + K <N) right[i] += right[i +K]; //cout << "RIGHT "<<p[i]<<": "<<right[i]<<endl; } 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...