#include <bits/stdc++.h>
/*
The sparkler should move in both directions from the initial person after it is lit
If two people meet, they should do so as soon as possible, otherwise it wouldn't make a difference
A path actually depends on the sum of distances of the first and last people from the person with the sparkler
*/
int main(){
std::ios::sync_with_stdio(0);
std::cin.tie(0);
long long n,k,t;
std::cin>>n>>k>>t;
k--;
std::vector<int> places;
for(int i=0;i<n;i++){
int a;
std::cin>>a;
places.push_back(a);
}
long long lower=-1,upper=1e9;//min distance a sparkler can burn for
//I forgot 0
while(lower+1<upper){
long long mid=(lower+upper)/2;
std::vector<std::vector<int>> dp(n,std::vector<int>(n));
dp[k][k]=1;
for(int i=0;i<n-1;i++){
for(int l=0;l+i<n;l++){
int r=l+i;
if(dp[l][r]){
if(r+1<n&&places[r+1]-places[l]<=mid*(i+1)){
dp[l][r+1]=1;
}
if(l&&places[r]-places[l-1]<=mid*(i+1)){
dp[l-1][r]=1;
}
}
}
}
if(dp[0][n-1]){
upper=mid;
}else{
lower=mid;
}
}
//std::cout<<upper<<'\n';
//upper/=2;//towards each other
std::cout<<(upper+2*t-1)/(2*t)<<'\n';
}
# |
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 |
1 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
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 |
1 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
28 ms |
2672 KB |
Output is correct |
23 |
Correct |
17 ms |
1820 KB |
Output is correct |
24 |
Correct |
25 ms |
2576 KB |
Output is correct |
25 |
Correct |
51 ms |
4588 KB |
Output is correct |
26 |
Correct |
59 ms |
4516 KB |
Output is correct |
27 |
Correct |
70 ms |
4452 KB |
Output is correct |
28 |
Correct |
57 ms |
4468 KB |
Output is correct |
29 |
Correct |
54 ms |
4556 KB |
Output is correct |
30 |
Correct |
52 ms |
4584 KB |
Output is correct |
31 |
Correct |
62 ms |
4456 KB |
Output is correct |
32 |
Correct |
59 ms |
4532 KB |
Output is correct |
33 |
Correct |
59 ms |
4528 KB |
Output is correct |
34 |
Correct |
60 ms |
4508 KB |
Output is correct |
35 |
Correct |
66 ms |
4520 KB |
Output is correct |
36 |
Correct |
52 ms |
4508 KB |
Output is correct |
37 |
Correct |
56 ms |
4560 KB |
Output is correct |
38 |
Correct |
54 ms |
4560 KB |
Output is correct |
39 |
Correct |
59 ms |
4608 KB |
Output is correct |
40 |
Correct |
52 ms |
4500 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 |
1 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
28 ms |
2672 KB |
Output is correct |
23 |
Correct |
17 ms |
1820 KB |
Output is correct |
24 |
Correct |
25 ms |
2576 KB |
Output is correct |
25 |
Correct |
51 ms |
4588 KB |
Output is correct |
26 |
Correct |
59 ms |
4516 KB |
Output is correct |
27 |
Correct |
70 ms |
4452 KB |
Output is correct |
28 |
Correct |
57 ms |
4468 KB |
Output is correct |
29 |
Correct |
54 ms |
4556 KB |
Output is correct |
30 |
Correct |
52 ms |
4584 KB |
Output is correct |
31 |
Correct |
62 ms |
4456 KB |
Output is correct |
32 |
Correct |
59 ms |
4532 KB |
Output is correct |
33 |
Correct |
59 ms |
4528 KB |
Output is correct |
34 |
Correct |
60 ms |
4508 KB |
Output is correct |
35 |
Correct |
66 ms |
4520 KB |
Output is correct |
36 |
Correct |
52 ms |
4508 KB |
Output is correct |
37 |
Correct |
56 ms |
4560 KB |
Output is correct |
38 |
Correct |
54 ms |
4560 KB |
Output is correct |
39 |
Correct |
59 ms |
4608 KB |
Output is correct |
40 |
Correct |
52 ms |
4500 KB |
Output is correct |
41 |
Runtime error |
122 ms |
262144 KB |
Execution killed with signal 9 |
42 |
Halted |
0 ms |
0 KB |
- |