Submission #975999

# Submission time Handle Problem Language Result Execution time Memory
975999 2024-05-06T04:53:46 Z vjudge1 Watching (JOI13_watching) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define pb push_back
#define endl '\n'
using namespace std;

int N,K,B,a[2005];

bool check(int x) {
	queue<pair<int, pair<int, int>>> p;
	p.push({1, {K, B}});
	while (!p.empty()) {
		auto cur = p.front();
		p.pop();
		int idx = cur.f;
		int ku = cur.s.f;
		int bu = cur.s.s;
		// cout << idx << ' ' << ku << ' ' << bu << endl;
		if (idx >= N + 1) return true;
		int nxt_idx = idx;
		if (ku > 0) {
			while (a[nxt_idx + 1] - a[idx] <= x && nxt_idx <= N) nxt_idx++;
			p.push({nxt_idx + 1, {ku - 1, bu}});
		}
		nxt_idx = idx;
		if (bu > 0) {
			while (a[nxt_idx + 1] - a[idx] <= 2 * x && nxt_idx <= N) nxt_idx++;
			p.push({nxt_idx + 1, {ku, bu - 1}});
		}
	}
	return false;
}

void solve() {
	cin >> N >> K >> B;
	for (int i = 1; i <= N; i++) cin >> a[i];
	sort(a + 1, a + 1 + N);
	int l = 1;
	int r = 1e9;
	int ans = -1;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (check(mid)) {
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	} cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tttt = 1;
	// cin >> tttt;
	while (tttt--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -