Submission #464985

#TimeUsernameProblemLanguageResultExecution timeMemory
464985Hamed5001Watching (JOI13_watching)C++14
0 / 100
121 ms31564 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 BS(int x){ int s=0,e=n-1; while(s<=e){ int mid=(s+e)>>1; if(arr[mid]>x)e=mid-1; else s=mid+1; } return e; } int check(int idx=0,int small=0){ if(small>sm) return 1e9; if(idx>=n) return 0; int &ret = dp[idx][small]; if(ret!=-1)return ret; ret=1e9; int r1 = (arr[idx] + mid) -1 ,r2 = (arr[idx] + (mid*2)) -1; int idx2 = upper_bound(arr, arr+n, r1) - arr,idx3 = upper_bound(arr, arr+n, r2) - arr; return ret = min(check(idx2,small+1), check(idx3,small)+1); } bool ok(){ memset(dp,-1,sizeof dp); check(); for(int i=0;i<=sm;i++){ if(dp[0][i]<=big&&dp[0][i]!=-1)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); 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...