제출 #744448

#제출 시각아이디문제언어결과실행 시간메모리
744448MODDI선물상자 (IOI15_boxes)C++14
0 / 100
1 ms304 KiB
#include <bits/stdc++.h>
#include "boxes.h"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
using namespace std;
long long delivery(int n, int k, int l, int p[]) {
    ll ans = 2e18;
    vl clockwise(n+5,0);
    for(ll i = 0;i < n;i++){
		if(i < k){
			clockwise[i + 1] = 2 * p[i];
		}else{
			clockwise[i + 1] = clockwise[i + 1 - k] + (2 * p[i]);
		}
	}
	vl anticlockwise(n+5, 0);
	for(ll i = n - 1;i >= 0;i--){
		if(i >= n - k + 1){
			anticlockwise[i + 1] = 2 * (l - p[i]);
		}else{
			anticlockwise[i + 1] = anticlockwise[i + 1 + k] + (2 * (l - p[i]));
		}
	}
	for(ll i = 0;i <= n;i++){
		ans = min(ans,clockwise[i] + anticlockwise[i + 1]);
	}
	for(ll i = 0;i <=n-k;i++){
		ans = min(ans,clockwise[i] + anticlockwise[i + 1 + k]);
	}
	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...