Submission #981227

# Submission time Handle Problem Language Result Execution time Memory
981227 2024-05-13T02:36:26 Z Amaarsaa Watching (JOI13_watching) C++14
0 / 100
1 ms 600 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long ;
ll a[2004];
ll n;
bool Can(ll x, ll s, ll small, ll large) {
	ll p;
	if ( s < 1) return 1;
	if ( small > 0) {
		p = lower_bound(a + 1, a + n + 1, a[s] - x + 1) - a;
		p --;
		if (Can(x, p, small- 1, large)) return 1;
	} 
	if ( large > 0) {
		p = lower_bound(a + 1, a + n + 1, a[s] - (2 * x) + 1) - a;
		p --;
		if (Can(x, p, small, large - 1)) return 1;	
	}
	return 0;
}

int main() {
//	freopen("moocast.in", "r", stdin);
//	freopen("moocast.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll i, lo, hi, mid, small, large;
	
	cin >> n >> small >> large;
	if ( small + large >= n) {
		cout << 1 << endl;
		return 0;
	}
	for (i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	sort ( a + 1, a + n + 1);
	lo = 1;
	hi = 1e9;
	
	while ( lo < hi) {
		mid = (lo + hi)/2;
		if ( !Can(mid, n, small, large)) lo = mid + 1;
		else hi = mid;
	}
	cout << lo + 1 << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -