Submission #671502

#TimeUsernameProblemLanguageResultExecution timeMemory
671502amunduzbaevSparklers (JOI17_sparklers)C++17
50 / 100
45 ms8268 KiB
#include "bits/stdc++.h" using namespace std; #define ar array typedef long long ll; #define int ll const int N = 1e3 + 5; int x[N], dp[N][N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k, T; cin >> n >> k >> T; for(int i=1;i<=n;i++){ cin >> x[i]; } x[n + 1] = x[n]; auto check = [&](int s){ int t = T * s * 2; memset(dp, 0, sizeof dp); dp[k][k] = 1; for(int d=0;d<n;d++){ for(int l=1, r=1+d;l+d<=n;l++, r++){ if(!dp[l][r]) continue; if(1 < l && (r - l + 1) * t >= x[r] - x[l - 1]){ dp[l - 1][r] = 1; } if(r < n && (r - l + 1) * t >= x[r + 1] - x[l]){ dp[l][r + 1] = 1; } } } return dp[1][n]; }; int l = 0, r = x[n] / (T * 2) + 1; while(l < r){ int m = (l + r) >> 1; if(check(m)) r = m; else l = m + 1; } cout<<l<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...