Submission #1080422

#TimeUsernameProblemLanguageResultExecution timeMemory
1080422isaachewSparklers (JOI17_sparklers)C++17
0 / 100
1 ms348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...