Submission #1251845

#TimeUsernameProblemLanguageResultExecution timeMemory
1251845ilhan_ardaWatching (JOI13_watching)C++20
0 / 100
14 ms9284 KiB
//~ #pragma GCC optimize("O3,unroll-loops") //~ #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define fi first #define se second #define pb push_back #define endl "\n" #define int long long using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef tuple<int, int, int> iii; const int inf = INT_MAX; const int mod = 1e9+7; int n, p, q, w; int a[105], dp[105][105][105]; bool f(int ind, int A, int b){ if(ind > n) return true; if(dp[ind][A][b] != -1) return (bool)dp[ind][A][b]; //kucuk if(A){ int ind2 = upper_bound(a+1, a+n+1, a[ind]+w-1) - a; //~ cout<<ind<<" .. "<<ind2<<" .. " << w<<endl; bool c = f(ind2, A-1, b); if(c)dp[ind][A][b] = 1; if(c)return true; } if(b){ int ind2 = upper_bound(a+1, a+n+1, a[ind]+w*2-1) - a; bool c = f(ind2, A, b-1); if(c)dp[ind][A][b] = 1; if(c)return true; } dp[ind][A][b] = 0; return false; } bool check(int x){ w = x; memset(dp, -1, sizeof(dp)); return f(1, p, q); } int32_t main(){ fast; cin>>n>>p>>q; for(int i=1;i<=n;i++){ cin>>a[i]; } sort(a+1, a+n+1); //~ for(int i=1;i<=n;i++){ //~ cout<<a[i]<<" "; //~ } if(p + q >= n){ cout<<1<<endl; } int l = 1, r = 1e9; while(l<=r){ int m = (l+r)/2; if(check(m)){ r = m-1; } else l = m+1; } cout<<l<<endl; } //https://usaco.org/current/current/index.php?page=viewproblem2&cpid=282 bunu coz //~ 10 15 19 33 53 66 66 68 75 83 83 93 99
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...