Submission #560125

#TimeUsernameProblemLanguageResultExecution timeMemory
560125amunduzbaevSparklers (JOI17_sparklers)C++17
50 / 100
226 ms262144 KiB
#include "bits/stdc++.h" using namespace std; #define ar array #define int long long const int inf = 1e9 + 5; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k, t; cin>>n>>k>>t; vector<int> a(n), d(n); for(int i=0;i<n;i++) cin>>a[i], a[i] *= 2; for(int i=1;i<n;i++){ d[i] = a[i] - a[i-1]; } k--; auto check = [&](int s){ vector<int> b(n); for(int i=0;i<n;i++) b[i] = a[i] / 2 - i * s * t; vector<vector<int>> dp(n, vector<int>(n, 0)); dp[k][k] = 1; for(int len=0;len<n;len++){ for(int i=0;i+len<n;i++){ int j=i+len; if(j+1<n && b[i] >= b[j+1]){ dp[i][j+1] |= dp[i][j]; } if(i && b[i-1] >= b[j]){ dp[i-1][j] |= dp[i][j]; } } } return dp[0][n-1]; }; int l = 0, r = 2 * inf; while(l < r){ int m = (l + r) >> 1; if(check(m)) r = m; else l = m + 1; } cout<<(l+1) / 2<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...