Submission #544584

#TimeUsernameProblemLanguageResultExecution timeMemory
544584krit3379Sure Bet (CEOI17_sure)C++14
0 / 100
1 ms312 KiB
#include<bits/stdc++.h> using namespace std; #define N 100005 double a[N],b[N],ans; int main(){ int n,i,l,r,mid; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%lf %lf",&a[i],&b[i]); sort(a+1,a+n+1,greater<double>()); sort(b+1,b+n+1,greater<double>()); for(i=1;i<=n;i++)a[i]+=a[i-1],b[i]+=b[i-1]; for(i=1;i<=2*n;i++){ l=0,r=min(i,n); while(l<=r){ mid=(l+r)/2; ans=max(ans,min(a[mid],b[min(i-mid,n)])-i); if(a[mid]>=b[i-mid])r=mid-1; else l=mid+1; } } printf("%.4lf",ans); return 0; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
sure.cpp:10:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(i=1;i<=n;i++)scanf("%lf %lf",&a[i],&b[i]);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...