Submission #465012

#TimeUsernameProblemLanguageResultExecution timeMemory
465012Hamed5001Watching (JOI13_watching)C++14
0 / 100
126 ms31692 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define all(v) v.begin(),v.end() #define gen(arr,n,nxt) generate(arr,arr+n,nxt) #define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0); const int mo=1e9+7,INF=1e18; int nxt(){int x;cin>>x;return x;} int n,sm,big,arr[2001],dp[2001][2001],mid; int check(int idx,int small){ if (small < 0) return 1e10; if (idx == -1) return 0; int &ret = dp[idx][small]; if (~ret) return ret; int idx1 = idx, idx2 = idx; while(idx1 >= 0 && arr[idx] - arr[idx1] < mid) idx1--; while(idx2 >= 0 && arr[idx] - arr[idx2] < 2*mid) idx2--; return ret = min(check(idx1, small-1), check(idx2, small)+1); } bool ok(){ memset(dp,-1,sizeof dp); for (int i = 0; i <= sm; i++) { check(n-1, i); } for (int i = 0; i <= sm; i++) { if (dp[n-1][i] <= big) return 1; } return 0; } signed main(){ Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty n=nxt(),sm=nxt(),big=nxt(); if(n<big)big=n; if(n<sm)sm=n; gen(arr,n,nxt); sort(arr,arr+n); mid = 2; int s=0,e=1e9,mn=1e9; while(s<=e){ if(e==1)break; mid=(s+e)>>1; if(ok()){ mn=min(mn,mid); e=mid-1; } else s=mid+1; } cout<<mn; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...