이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |