#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |