Submission #544585

# Submission time Handle Problem Language Result Execution time Memory
544585 2022-04-02T11:45:18 Z krit3379 Sure Bet (CEOI17_sure) C++14
100 / 100
73 ms 3532 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[min(i-mid,n)])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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 68 ms 3148 KB Output is correct
18 Correct 67 ms 3100 KB Output is correct
19 Correct 73 ms 3212 KB Output is correct
20 Correct 67 ms 3100 KB Output is correct
21 Correct 72 ms 3532 KB Output is correct
22 Correct 69 ms 3144 KB Output is correct
23 Correct 67 ms 3152 KB Output is correct
24 Correct 67 ms 3196 KB Output is correct
25 Correct 66 ms 3216 KB Output is correct
26 Correct 70 ms 3472 KB Output is correct