# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551049 | LucaDantas | Sparklers (JOI17_sparklers) | C++17 | 50 ms | 4416 KiB |
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;
constexpr int maxn = 1010, inf = 0x3f3f3f3f;
int x[maxn], n, k, T, v;
int dp[maxn][maxn];
void solve(int l, int r) {
if(dp[l][r]) return;
dp[l][r] = 1;
if(l && (x[r] - x[l-1]) <= 1ll * 2 * v * T * (r-l+1))
solve(l-1, r);
if(r < n-1 && (x[r+1] - x[l]) <= 1ll * 2 * v * T * (r-l+1))
solve(l, r+1);
}
int main() {
scanf("%d %d %d", &n, &k, &T); --k; // 0-indexed
for(int i = 0; i < n; i++)
scanf("%d", x+i);
int l = 0, r = inf, ans = -1;
while(l <= r) {
int m = (l+r) >> 1;
v = m;
memset(dp, 0, sizeof dp);
solve(k, k);
if(dp[0][n-1])
r = m-1, ans = m;
else
l = m+1;
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |