Submission #468185

#TimeUsernameProblemLanguageResultExecution timeMemory
468185pdstiagoWatching (JOI13_watching)C++14
0 / 100
1092 ms332 KiB
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define mxn 2005 #define mxm 1005 #define f first #define s second #define pb push_back #define es " " #define endl '\n' #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3f #define ll long long #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() typedef pair<ll, ll> pii; typedef pair<pii, int> pip; int n, p, g; vector<int> v; int solve(int i, int ss, int b, int maxx){ if(ss<0 || b<0){ return 0; } if(i>=n){ return 1; } auto it1=upper_bound(v.begin()+i, v.end(), v[i]+maxx-1); auto it2=upper_bound(v.begin()+i, v.end(), v[i]+2*maxx-1); it1--; it2--; int pos1=it1-v.begin(), pos2=it2-v.begin(); return max(solve(pos1+1, ss-1, b, maxx), solve(pos2+1, ss, b-1, maxx)); } int main(){ fastio; cin >> n >> p >> g; for(int i=1; i<=n; i++){ int x; cin >> x; v.pb(x); } sort(all(v)); int ini=1, fim=1000000000, meio, resp; while(ini<=fim){ meio=(ini+fim)>>1; if(solve(0, p, g, meio)){ resp=meio; fim=meio-1; }else{ ini=meio+1; } } cout << resp; return 0; }

Compilation message (stderr)

watching.cpp: In function 'int main()':
watching.cpp:58:13: warning: 'resp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   58 |     cout << resp;
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...