Submission #878967

#TimeUsernameProblemLanguageResultExecution timeMemory
878967eitanelbSparklers (JOI17_sparklers)C++14
50 / 100
153 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; bool ok(int n, int k, vector<int>&v, ll m){ bool dp[n][n]; for(int i=0;i<n;i++)for(int j=0;j<n;j++) dp[i][j]=0; dp[k-1][k-1]=1; for(int sz=2;sz<=n;sz++){ for(int i=0;i+sz-1 < n;i++){ if(((v[i+sz-1]-v[i]) <= 2*m*(sz-1)) && (dp[i][i+sz-2] || dp[i+1][i+sz-1])) dp[i][i+sz-1]=1; } } //cout<<m<<' '<<dp[0][n-1]<<endl; return dp[0][n-1]; } int func(int n, int k, int t, vector<int>&v){ int s=0, e=1e9, m; while(e>s){ m = (e+s)/2; if(ok(n,k,v,m)) e=m; else s=m+1; } return (s+t-1)/t; } int main(){ ios::sync_with_stdio(0); cin.tie(0); int n,k,t; cin>>n>>k>>t; vector<int> v(n); for(int i=0;i<n;i++) cin>>v[i]; int res = func(n,k,t,v); cout<<res<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...