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>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
int dp[1005][1005];
signed main() {
int n, id, t, l=1, r=1e9, ans=1e9; cin >> n >> id >> t;
vector<ll> v(n+1);
for(int i=1; i<=n; i++) cin >> v[i];
r = ans = v[n] / t + 1;
while(l <= r) {
int mid = (l + r) / 2;
memset(dp, 0, sizeof(dp));
dp[id][id] = 1;
for(int len=2; len<=n; len++)
for(int i=1, j=len; j<=n; i++,j++)
if(v[j] - v[i] <= 2ll * mid * (j - i) * t) dp[i][j] = (dp[i+1][j] || dp[i][j-1]);
if(dp[1][n]) ans = mid, r = mid - 1;
else l = mid + 1;
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |