Submission #544584

# Submission time Handle Problem Language Result Execution time Memory
544584 2022-04-02T11:37:33 Z krit3379 Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 312 KB
#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

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 time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -