Submission #1130402

#TimeUsernameProblemLanguageResultExecution timeMemory
1130402heeyWatching (JOI13_watching)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h>
using namespace std;

int n, p, q;
int a[2001];

bool moze(int w){
	int sm = p, big = q;
	for(int i = 0; i < n-1; i++){
		int dst = a[i+1] - a[i] + 1;
		if(dst > 2*w){
			if(sm > 0) sm--;
			else big--;
		}
		else if(dst > w){
			if(big > 0) {
				big--;
				i++;
			}
			else sm--;
		}
		else{
			sm--;
			int c = a[i];
			i++;
			while(i < n-1 && a[i] - c + 1 <= w) i++;
			i--;
		}
	}

	return sm >0 || big > 0;

}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> p >> q;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	int l = 1, r = 1e9;	
	while(l <= r){
		int m = (l+r)>>1;
		if(moze(m)){
			r = m-1;
		}
		else l = m+1;
	}
	cout << r << '\n';
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...