Submission #173688

# Submission time Handle Problem Language Result Execution time Memory
173688 2020-01-05T00:09:37 Z rzbt Sure Bet (CEOI17_sure) C++14
100 / 100
88 ms 5364 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 100005
typedef long long ll;


using namespace std;
int n;
double a[MAXN],b[MAXN],prefb[MAXN],prefa[MAXN],res;

int bin(int l,int d,int pa,int sol){
    if(l>d)return sol;
    int mid=(l+d)/2;
    if(prefa[pa]-mid>prefb[mid]-pa)return bin(mid+1,d,pa,mid);
    return bin(l,mid-1,pa,sol);
}


int main()///NE MORA DA VUDE POVEZAN
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%lf %lf",a+i,b+i);
    }
    double res=0.0;

    sort(a+1,a+1+n,greater<double>());
    sort(b+1,b+1+n,greater<double>());
    for(int i=1;i<=n;i++){
        prefb[i]=prefb[i-1]+b[i]-1.0;
        prefa[i]=prefa[i-1]+a[i]-1.0;
    }
    for(int i=1;i<=n;i++){
        int ok=bin(0,n,i,0);
        //printf("  %d %d    %f %f\n",i,ok,prefa[i],prefb[ok]);
        res=max(res,min(prefa[i]-ok,prefb[ok]-i));
        if(ok!=n)res=max(res,min(prefa[i]-ok-1,prefb[ok+1]-i));
    }
    printf("%.4f",res);

    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
sure.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf %lf",a+i,b+i);
         ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 380 KB Output is correct
17 Correct 83 ms 4828 KB Output is correct
18 Correct 83 ms 4828 KB Output is correct
19 Correct 84 ms 4828 KB Output is correct
20 Correct 86 ms 4860 KB Output is correct
21 Correct 88 ms 5364 KB Output is correct
22 Correct 85 ms 4856 KB Output is correct
23 Correct 84 ms 4860 KB Output is correct
24 Correct 84 ms 4860 KB Output is correct
25 Correct 83 ms 4828 KB Output is correct
26 Correct 86 ms 5320 KB Output is correct