Submission #651617

# Submission time Handle Problem Language Result Execution time Memory
651617 2022-10-19T13:08:14 Z Koful123 Watching (JOI13_watching) C++14
0 / 100
1 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define int long long

int n,p,q;
vector<int> v;
vector<vector<vector<bool>>> dp,ok;

bool f(int pos,int p,int q,int w){
	if(p < 0 || q < 0) return false;
	if(pos >= n) return true;
	if(ok[pos][p][q]) return dp[pos][p][q];
	int a = lower_bound(all(v),v[pos] + w) - v.begin();
	int b = lower_bound(all(v),v[pos] + 2*w) - v.begin();
	dp[pos][p][q] = (f(a,p-1,q,w) || f(b,p,q-1,w)); ok[pos][p][q] = true;
	return dp[pos][p][q];
}

bool check(int m){
	for(int i=0;i<=n;i++){
		for(int j=0;j<=p;j++){
			for(int k=0;k<=q;k++){
				dp[i][j][k] = ok[i][j][k] = false;
			}
		}
	}
	return f(0,p,q,m);
}

void solve(){

	cin >> n >> p >> q;
	v.assign(n,0);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}

	if(p + q >= n){
		cout << 1 << endl;
		return;
	}

	sort(all(v));
	int l = 1,r = 1e9;
	while(l < r){
		int m = (l + r) / 2;
		if(check(m)) r = m;
		else l = m + 1;
	}

	cout << l << endl;
}	

signed main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
//	cin >> t;

	while(t--)
		solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -