#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
cin.sync_with_stdio(0); cin.tie(0);
LL n, k, t;
cin >> n >> k >> t;
k--;
vector<LL> x(n);
for(int i = 0; i < n; i++){
cin >> x[i];
}
LL s = -1;
LL e = 1000000000;
LL dp[n][n];
while(s + 1 < e){
LL m = (s + e) / 2;
vector<LL> y = x;
for(LL i = 0; i < n; i++){
y[i] -= m * t * 2 * i;
}
for(LL i = k; i >= 0; i--){
for(LL j = k; j < n; j++){
dp[i][j] = 0;
if(y[j] <= y[i]){
if((i == k && j == k) || (i < k && dp[i+1][j]) || (j > k && dp[i][j-1])){
dp[i][j] = 1;
}
}
}
}
if(dp[0][n-1]){
e = m;
} else {
s = m;
}
}
cout << e << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
508 KB |
Output is correct |
5 |
Correct |
3 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
508 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
636 KB |
Output is correct |
9 |
Correct |
3 ms |
636 KB |
Output is correct |
10 |
Correct |
2 ms |
636 KB |
Output is correct |
11 |
Correct |
3 ms |
692 KB |
Output is correct |
12 |
Correct |
2 ms |
692 KB |
Output is correct |
13 |
Correct |
2 ms |
692 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
17 |
Correct |
2 ms |
692 KB |
Output is correct |
18 |
Correct |
2 ms |
692 KB |
Output is correct |
19 |
Correct |
4 ms |
692 KB |
Output is correct |
20 |
Correct |
3 ms |
692 KB |
Output is correct |
21 |
Correct |
2 ms |
692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
508 KB |
Output is correct |
5 |
Correct |
3 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
508 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
636 KB |
Output is correct |
9 |
Correct |
3 ms |
636 KB |
Output is correct |
10 |
Correct |
2 ms |
636 KB |
Output is correct |
11 |
Correct |
3 ms |
692 KB |
Output is correct |
12 |
Correct |
2 ms |
692 KB |
Output is correct |
13 |
Correct |
2 ms |
692 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
17 |
Correct |
2 ms |
692 KB |
Output is correct |
18 |
Correct |
2 ms |
692 KB |
Output is correct |
19 |
Correct |
4 ms |
692 KB |
Output is correct |
20 |
Correct |
3 ms |
692 KB |
Output is correct |
21 |
Correct |
2 ms |
692 KB |
Output is correct |
22 |
Correct |
16 ms |
2152 KB |
Output is correct |
23 |
Correct |
7 ms |
2152 KB |
Output is correct |
24 |
Correct |
5 ms |
2152 KB |
Output is correct |
25 |
Correct |
4 ms |
2152 KB |
Output is correct |
26 |
Correct |
13 ms |
2152 KB |
Output is correct |
27 |
Correct |
19 ms |
2152 KB |
Output is correct |
28 |
Correct |
23 ms |
4840 KB |
Output is correct |
29 |
Correct |
21 ms |
4972 KB |
Output is correct |
30 |
Correct |
19 ms |
4972 KB |
Output is correct |
31 |
Correct |
17 ms |
5100 KB |
Output is correct |
32 |
Correct |
22 ms |
5100 KB |
Output is correct |
33 |
Correct |
21 ms |
5100 KB |
Output is correct |
34 |
Correct |
13 ms |
5100 KB |
Output is correct |
35 |
Correct |
19 ms |
5100 KB |
Output is correct |
36 |
Correct |
8 ms |
5100 KB |
Output is correct |
37 |
Correct |
8 ms |
5100 KB |
Output is correct |
38 |
Correct |
22 ms |
5100 KB |
Output is correct |
39 |
Correct |
10 ms |
5100 KB |
Output is correct |
40 |
Correct |
18 ms |
5100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
3 ms |
508 KB |
Output is correct |
5 |
Correct |
3 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
508 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
636 KB |
Output is correct |
9 |
Correct |
3 ms |
636 KB |
Output is correct |
10 |
Correct |
2 ms |
636 KB |
Output is correct |
11 |
Correct |
3 ms |
692 KB |
Output is correct |
12 |
Correct |
2 ms |
692 KB |
Output is correct |
13 |
Correct |
2 ms |
692 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
692 KB |
Output is correct |
16 |
Correct |
3 ms |
692 KB |
Output is correct |
17 |
Correct |
2 ms |
692 KB |
Output is correct |
18 |
Correct |
2 ms |
692 KB |
Output is correct |
19 |
Correct |
4 ms |
692 KB |
Output is correct |
20 |
Correct |
3 ms |
692 KB |
Output is correct |
21 |
Correct |
2 ms |
692 KB |
Output is correct |
22 |
Correct |
16 ms |
2152 KB |
Output is correct |
23 |
Correct |
7 ms |
2152 KB |
Output is correct |
24 |
Correct |
5 ms |
2152 KB |
Output is correct |
25 |
Correct |
4 ms |
2152 KB |
Output is correct |
26 |
Correct |
13 ms |
2152 KB |
Output is correct |
27 |
Correct |
19 ms |
2152 KB |
Output is correct |
28 |
Correct |
23 ms |
4840 KB |
Output is correct |
29 |
Correct |
21 ms |
4972 KB |
Output is correct |
30 |
Correct |
19 ms |
4972 KB |
Output is correct |
31 |
Correct |
17 ms |
5100 KB |
Output is correct |
32 |
Correct |
22 ms |
5100 KB |
Output is correct |
33 |
Correct |
21 ms |
5100 KB |
Output is correct |
34 |
Correct |
13 ms |
5100 KB |
Output is correct |
35 |
Correct |
19 ms |
5100 KB |
Output is correct |
36 |
Correct |
8 ms |
5100 KB |
Output is correct |
37 |
Correct |
8 ms |
5100 KB |
Output is correct |
38 |
Correct |
22 ms |
5100 KB |
Output is correct |
39 |
Correct |
10 ms |
5100 KB |
Output is correct |
40 |
Correct |
18 ms |
5100 KB |
Output is correct |
41 |
Runtime error |
17 ms |
5100 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
42 |
Halted |
0 ms |
0 KB |
- |