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 finish(x) return cout << x << endl, 0
#define ll long long
#define ld long double
const int N = 1001;
int n, k, T;
ld dp[N][N];
vector <int> x;
ld calc(ll d, ld t, ld s){
d /= 2;
return t - d / s;
}
bool can(int s){
for(int l = 0 ; l < n ; l++){
for(int r = l + 1 ; r < n ; r++){
dp[l][r] = -1;
}
}
dp[k][k] = T;
for(int len = 2 ; len <= n ; len++){
for(int l = 0, r = len - 1 ; r < n ; l++, r++){
if(dp[l + 1][r] > 0){
ld new_t = calc(x[l + 1] - x[l], dp[l + 1][r], s);
if(new_t > 0){
dp[l][r] = max(dp[l][r], new_t + T);
}
}
if(dp[l][r - 1] > 0){
ld new_t = calc(x[r] - x[r - 1], dp[l][r - 1], s);
if(new_t > 0){
dp[l][r] = max(dp[l][r], new_t + T);
}
}
}
}
return dp[0][n - 1] > 0;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> T;
x.resize(n);
for(auto &i : x) cin >> i;
k--;
if(x.back() - x[0] == 0) finish(0);
int l = 1, r = 1e9;
while(l <= r){
int mid = (l + r) / 2;
if(can(mid)) r = mid - 1;
else l = mid + 1;
}
cout << l << 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... |