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;
#define ar array
typedef long long ll;
#define int ll
const int N = 1e3 + 5;
int x[N], dp[N][N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n, k, T; cin >> n >> k >> T;
for(int i=1;i<=n;i++){
cin >> x[i];
}
x[n + 1] = x[n];
auto check = [&](int s){
int t = T * s * 2;
memset(dp, 0, sizeof dp);
dp[k][k] = 1;
for(int d=0;d<n;d++){
for(int l=1, r=1+d;l+d<=n;l++, r++){
if(!dp[l][r]) continue;
if(1 < l && (r - l + 1) * t >= x[r] - x[l - 1]){
dp[l - 1][r] = 1;
}
if(r < n && (r - l + 1) * t >= x[r + 1] - x[l]){
dp[l][r + 1] = 1;
}
}
}
return dp[1][n];
};
int l = 0, r = x[n] / (T * 2) + 1;
while(l < r){
int m = (l + r) >> 1;
if(check(m)) r = m;
else l = m + 1;
}
cout<<l<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |