제출 #1166143

#제출 시각아이디문제언어결과실행 시간메모리
1166143Tsagana구경하기 (JOI13_watching)C++20
0 / 100
1 ms328 KiB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second


#define op1 x--; r = a[i] - 1 + k; continue
#define op2 y--; r = a[i] - 1 + 2 * k; continue

using namespace std;

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

bool check(int k) {
	int r = 0;
	int x = p, y = q;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= r) continue ;
		if (!x) {if (!y) return 0; op2;}
		if (!y) {op1;}
		
		if (a[i+1] - a[i] < 2 * k) {op2;}
		else {op1;}
	}
	return 1;
}

int search(int l, int r) {
	while (l < r) {
		int m = (l + r) / 2;
		if (check(m)) r = m;
		else l = m + 1;
	}
	return l;
}

void solve () {
	cin >> n >> p >> q;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[n+1] = INT_MAX;
	sort(a, a+n+1);
	cout << search(1, 1000000000);
}
signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...