#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll n, k, t, i, j, a, lo = 1, hi = (1 << 30), s;
cin >> n >> k >> t;
k--;
vector<ll> v(n);
for (i = 0; i < n; i++)
cin >> v[i];
if (!v[n - 1])
{
cout << 0;
return 0;
}
vector<vector<bool> > dp(n);
queue<vector<ll> > q;
for (i = 0; i < n; i++)
dp[i].resize(i + 1);
while (hi - lo > 1)
{
s = (hi + lo) / 2;
for (i = 0; i < n; i++)
{
for (j = 0; j <= i; j++)
dp[i][j] = 0;
}
dp[k][k] = 1;
q.push({k, k});
while (!q.empty())
{
i = q.front()[0];
j = q.front()[1];
q.pop();
a = 2 * t * s * (i - j + 1);
if (j && !dp[i][j - 1] && v[i] - v[j - 1] <= a)
{
dp[i][j - 1] = 1;
q.push({i, j - 1});
}
if (i < n - 1 && !dp[i + 1][j] && v[i + 1] - v[j] <= a)
{
dp[i + 1][j] = 1;
q.push({i + 1, j});
}
}
if (dp[n - 1][0])
hi = s;
else
lo = s;
}
cout << hi;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
64 ms |
348 KB |
Output is correct |
23 |
Correct |
40 ms |
348 KB |
Output is correct |
24 |
Correct |
25 ms |
348 KB |
Output is correct |
25 |
Correct |
29 ms |
348 KB |
Output is correct |
26 |
Correct |
80 ms |
348 KB |
Output is correct |
27 |
Correct |
79 ms |
568 KB |
Output is correct |
28 |
Correct |
111 ms |
580 KB |
Output is correct |
29 |
Correct |
134 ms |
344 KB |
Output is correct |
30 |
Correct |
91 ms |
600 KB |
Output is correct |
31 |
Correct |
91 ms |
344 KB |
Output is correct |
32 |
Correct |
116 ms |
604 KB |
Output is correct |
33 |
Correct |
150 ms |
600 KB |
Output is correct |
34 |
Correct |
72 ms |
348 KB |
Output is correct |
35 |
Correct |
130 ms |
344 KB |
Output is correct |
36 |
Correct |
59 ms |
560 KB |
Output is correct |
37 |
Correct |
56 ms |
348 KB |
Output is correct |
38 |
Correct |
97 ms |
344 KB |
Output is correct |
39 |
Correct |
47 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
64 ms |
348 KB |
Output is correct |
23 |
Correct |
40 ms |
348 KB |
Output is correct |
24 |
Correct |
25 ms |
348 KB |
Output is correct |
25 |
Correct |
29 ms |
348 KB |
Output is correct |
26 |
Correct |
80 ms |
348 KB |
Output is correct |
27 |
Correct |
79 ms |
568 KB |
Output is correct |
28 |
Correct |
111 ms |
580 KB |
Output is correct |
29 |
Correct |
134 ms |
344 KB |
Output is correct |
30 |
Correct |
91 ms |
600 KB |
Output is correct |
31 |
Correct |
91 ms |
344 KB |
Output is correct |
32 |
Correct |
116 ms |
604 KB |
Output is correct |
33 |
Correct |
150 ms |
600 KB |
Output is correct |
34 |
Correct |
72 ms |
348 KB |
Output is correct |
35 |
Correct |
130 ms |
344 KB |
Output is correct |
36 |
Correct |
59 ms |
560 KB |
Output is correct |
37 |
Correct |
56 ms |
348 KB |
Output is correct |
38 |
Correct |
97 ms |
344 KB |
Output is correct |
39 |
Correct |
47 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Runtime error |
132 ms |
262144 KB |
Execution killed with signal 9 |
42 |
Halted |
0 ms |
0 KB |
- |