#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1003;
const int infint = (int)2e9;
const ll inf = (ll)2e18;
ll dp[MAXN][MAXN], part[MAXN], a[MAXN], dist[MAXN], n, k, T;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> k >> T;
for (int i = 1; i <= n; i++)
cin >> a[i];
T *= 2;
for (int i = 1; i <= n; i++)
dp[i][i] = -1;
dp[k][k] = 0;
for (int len = 1; len < n; len++)
for (int i = 1; i <= n - len; i++)
{
int j = i + len;
if(dp[i + 1][j] == -1 && dp[i][j - 1] == -1)
dp[i][j] = -1;
else
if(dp[i + 1][j] == -1)
dp[i][j] = dp[i][j - 1];
else
if(dp[i][j - 1] == -1)
dp[i][j] = dp[i + 1][j];
else
dp[i][j] = min(dp[i + 1][j], dp[i][j - 1]);
if(dp[i][j] != -1)
dp[i][j] = max(dp[i][j], (a[j] - a[i] + (j - i) * T - 1) / ((j - i) * T));
/*if(dp[i][j] != -1)
{
cout << "# " << j - i + 1 << " " << k - i + 1 << " " << T / 2 << endl;
for (int t = i; t <= j; t++)
cout << a[t] << " ";
cout << "\n";
cout << "---> " << dp[i][j] << "\n";
}*/
}
cout << dp[1][n];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
19 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
424 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
19 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
424 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
7 ms |
5248 KB |
Output is correct |
23 |
Correct |
6 ms |
3840 KB |
Output is correct |
24 |
Correct |
8 ms |
5120 KB |
Output is correct |
25 |
Correct |
12 ms |
7296 KB |
Output is correct |
26 |
Correct |
16 ms |
7296 KB |
Output is correct |
27 |
Correct |
15 ms |
7296 KB |
Output is correct |
28 |
Correct |
13 ms |
7296 KB |
Output is correct |
29 |
Correct |
14 ms |
7296 KB |
Output is correct |
30 |
Correct |
13 ms |
7296 KB |
Output is correct |
31 |
Correct |
14 ms |
7296 KB |
Output is correct |
32 |
Correct |
14 ms |
7296 KB |
Output is correct |
33 |
Correct |
14 ms |
7296 KB |
Output is correct |
34 |
Correct |
13 ms |
7296 KB |
Output is correct |
35 |
Correct |
15 ms |
7296 KB |
Output is correct |
36 |
Correct |
12 ms |
7296 KB |
Output is correct |
37 |
Correct |
14 ms |
7296 KB |
Output is correct |
38 |
Correct |
14 ms |
7296 KB |
Output is correct |
39 |
Correct |
11 ms |
7296 KB |
Output is correct |
40 |
Correct |
12 ms |
7296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
19 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
424 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
7 ms |
5248 KB |
Output is correct |
23 |
Correct |
6 ms |
3840 KB |
Output is correct |
24 |
Correct |
8 ms |
5120 KB |
Output is correct |
25 |
Correct |
12 ms |
7296 KB |
Output is correct |
26 |
Correct |
16 ms |
7296 KB |
Output is correct |
27 |
Correct |
15 ms |
7296 KB |
Output is correct |
28 |
Correct |
13 ms |
7296 KB |
Output is correct |
29 |
Correct |
14 ms |
7296 KB |
Output is correct |
30 |
Correct |
13 ms |
7296 KB |
Output is correct |
31 |
Correct |
14 ms |
7296 KB |
Output is correct |
32 |
Correct |
14 ms |
7296 KB |
Output is correct |
33 |
Correct |
14 ms |
7296 KB |
Output is correct |
34 |
Correct |
13 ms |
7296 KB |
Output is correct |
35 |
Correct |
15 ms |
7296 KB |
Output is correct |
36 |
Correct |
12 ms |
7296 KB |
Output is correct |
37 |
Correct |
14 ms |
7296 KB |
Output is correct |
38 |
Correct |
14 ms |
7296 KB |
Output is correct |
39 |
Correct |
11 ms |
7296 KB |
Output is correct |
40 |
Correct |
12 ms |
7296 KB |
Output is correct |
41 |
Runtime error |
25 ms |
9856 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
42 |
Halted |
0 ms |
0 KB |
- |