제출 #1355111

#제출 시각아이디문제언어결과실행 시간메모리
1355111gvancak구경하기 (JOI13_watching)C++20
50 / 100
1096 ms31732 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const ll N=2005,INF=1e9;
ll a[N],l,r,x,y,z,ans,t,n,q,mx,mn,k,p,dp[N][N];
bool ok,okk;
bool check(ll x){
	for (int i=0; i<=n; i++){
		for (int j=0; j<=p; j++) dp[i][j]=INF;
	}
	for (int i=0; i<=p; i++) dp[0][i]=0;
	for (int i=1; i<=n; i++){
		for (int j=0; j<=p; j++){
			// patara
			if (j!=0){
			int ind=lower_bound(a+1,a+n+1,a[i]-x+1)-a-1;
			dp[i][j]=min(dp[i][j],dp[ind][j-1]);
		}
			//didi
			int ind=lower_bound(a+1,a+n+1,a[i]-2*x+1)-a-1;
			dp[i][j]=min(dp[i][j],dp[ind][j]+1);
		//	cout<<i<<" "<<j<<" "<<dp[i][j]<<" IND: "<<ind<<endl;
		}
	}
//	cout<<x<<" "<<dp[n][p]<<endl;
	if (dp[n][p]<=q) return 1;
	return 0;
	
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    t=1;
    cin >> n >> p >> q;
    for (int i=1; i<=n; i++){
    	cin >> a[i];
	}
	if (p+q>=n){
		cout<<1<<endl; return 0;
	}
	sort(a+1,a+n+1);
	ans=0;
	for (int i=30; i>=0; i--){
		ans+=(1<<i);
		if (check(ans)==1) ans-=(1<<i);
	}
	cout << ans+1 << endl;

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...