Submission #208134

#TimeUsernameProblemLanguageResultExecution timeMemory
208134YJUWatching (JOI13_watching)C++17
50 / 100
1066 ms32052 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef long double ld; const ll MOD=1e9+7; const ll N=2e3+5; const ld pi=3.14159265359; const ll INF=(1LL<<62); #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(a) (ll)a.size() ll n,P,Q,x,DP[N][N]; vector<ll> v; bool b(ll k){ memset(DP,0,sizeof(DP)); DP[0][0]=0; REP(i,P+1)REP(j,Q+1){ DP[i][j+1]=max(DP[i][j+1],(ll)(lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin())); DP[i+1][j]=max(DP[i+1][j],(ll)(lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin())); if(DP[i][j]==n)return 1; } return 0; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>P>>Q; P=min(P,n);Q=min(Q,n); REP(i,n)cin>>x,v.pb(x); sort(v.begin(),v.end()); ll l=-1,r=MOD; while(r-l>1){ (b((r+l)/2)?r=(r+l)/2:l=(r+l)/2); } cout<<r<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...