Submission #92647

#TimeUsernameProblemLanguageResultExecution timeMemory
92647LittleFlowers__구경하기 (JOI13_watching)C++14
0 / 100
3 ms636 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N=500010; int n,p,q; int a[N]; bool C(int x) { ///2 ,11 ,17 int P=p,Q=q,i=1; while(i<=n) { if(!P && !Q) return 0; //cout<<i<<" "<<P<<" "<<Q<<"\n"; if(a[i]+x*2-1<a[i+1]) (P>0 ? P : Q)--,i++; else { int u=-1,v=-1; if(Q) u=upper_bound(a+1,a+n+1,a[i]+x*2-1)-a; if(P) v=upper_bound(a+1,a+n+1,a[i]+x-1)-a; //cout<<a[i] + x*2<<" "<<a[i+1]<<"\n"; if(u>v) { Q--; i=u; } else { P--; i=v; } } } return 1; } main() { //freopen("WATCHING.inp","r",stdin); cin>>n>>p>>q; for(int i=1;i<=n;++i) cin>>a[i]; sort(a+1,a+n+1); int l=1,m,r=1e9,ans; while(l<=r) { m=l+(r-l)/2; if(C(m)) ans=m,r=m-1; else l=m+1; } cout<<ans; }

Compilation message (stderr)

watching.cpp:36:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...