Submission #132766

#TimeUsernameProblemLanguageResultExecution timeMemory
132766miguelWatching (JOI13_watching)C++14
0 / 100
6 ms380 KiB
#include<bits/stdc++.h> //#include<gondola.h> using namespace std; #define rc(x) return cout<<x<<endl,0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define int ll #define sz size() #define x first #define y second #define pi pair <int, int> #define pii pair <int, pi> #define vi vector <int> const ll mod = 998244353; int n, p, q; vector <int> w; bool check(int d){ int a=p, b=q, cnt=0, cur=0; while(a+b){ bool ctrl=1; if(b){ if((*upper_bound(w.begin(), w.end(), w[cur]+d-1))<=w[cur]+2*d-1){ b--; ctrl=0; cur=upper_bound(w.begin(), w.end(), w[cur]+2*d-1)-w.begin(); } } if(a && ctrl){ a--; ctrl=0; cur=upper_bound(w.begin(), w.end(), w[cur]+d-1)-w.begin(); } if(b && ctrl){ b--; ctrl=0; cur=upper_bound(w.begin(), w.end(), w[cur]+2*d-1)-w.begin(); } if(cur>=n) return 1; } return 0; } int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>n>>p>>q; for(int i=1; i<=n; i++){ int x; cin>>x; w.pb(x); } int l=0, r=1e9+1; sort(w.begin(), w.end()); //w.pb(1000000001); while(r-l>1){ int mid=(l+r)>>1; if(check(mid)) r=mid; else l=mid; } cout<<r; }

Compilation message (stderr)

watching.cpp: In function 'bool check(long long int)':
watching.cpp:20:19: warning: unused variable 'cnt' [-Wunused-variable]
     int a=p, b=q, cnt=0, cur=0;
                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...