This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
bool ok(int n, int k, vector<int>&v, long m){
bool dp[n][n];
for(int i=0;i<n;i++)for(int j=0;j<n;j++) dp[i][j]=0;
dp[k-1][k-1]=1;
for(int sz=2;sz<=n;sz++){
for(int i=0;i+sz-1 < n;i++){
if(((v[i+sz-1]-v[i]) <= 2*m*(sz-1)) && (dp[i][i+sz-2] || dp[i+1][i+sz-1])) dp[i][i+sz-1]=1;
}
}
//cout<<m<<' '<<dp[0][n-1]<<endl;
return dp[0][n-1];
}
int func(int n, int k, int t, vector<int>&v){
int s=1, e=1e9, m;
while(e>s){
m = (e+s)/2;
if(ok(n,k,v,m)) e=m;
else s=m+1;
}
return (s+t-1)/t;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int n,k,t;
cin>>n>>k>>t;
vector<int> v(n);
for(int i=0;i<n;i++) cin>>v[i];
int res = func(n,k,t,v);
cout<<res<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |