제출 #673723

#제출 시각아이디문제언어결과실행 시간메모리
673723Hacv16선물상자 (IOI15_boxes)C++17
0 / 100
0 ms212 KiB
#include<bits/stdc++.h>
using namespace std;

const int INF = 0x3f3f3f3f;

int getDist(int x, int y, int l){
	if(y > x) swap(x, y);
	return min(x - y, l - x + y);
}

int delivery(int n, int k, int l, int p[]){
	int ans = INF;

	if(k == 1){
		for(int i = 0; i < n; i++)
			ans += 2 * getDist(0, p[i], l);

	}else if(k == n){
		int mn = p[0], mx = p[n - 1];
		ans = min(ans, getDist(0, mx, l) + getDist(mx, mn, l) + getDist(mn, 0, l));
		ans = min(ans, getDist(0, mn, l) + getDist(mn, mx, l) + getDist(mx, 0, l));
	}

	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...