Submission #361629

# Submission time Handle Problem Language Result Execution time Memory
361629 2021-01-30T20:58:45 Z bigDuck Sure Bet (CEOI17_sure) C++14
100 / 100
178 ms 16236 KB
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], b[100010];


int s1[100010], s2[100010];
multiset<pii> sum1, sum2;
const long long q=100000000;
int32_t main(){
INIT
cin>>n;

for(int i=1; i<=n; i++){
    double d; cin>>d;

    a[i]= d*q;
    //cout<<d<<"\n";
    cin>>d;

    b[i]=d*q;

    if( (b[i]%(q/10000))>0 ){
        b[i]-=b[i]%(q/10000);
        b[i]+=(q/10000);
    }
    if( (a[i]%(q/10000))>0 ){
        a[i]-=a[i]%(q/10000);
        a[i]+=(q/10000);
    }
   // cout<<a[i]<<" "<<b[i]<<"\n";
}

sort(a+1, a+1+n);
sort(b+1, b+1+n);


for(int i=n; i>=0; i--){
    s1[i]=s1[i+1]+a[i];
    sum1.insert({s1[i], i});
    s2[i]=s2[i+1]+b[i];
    sum2.insert({s2[i], i});
}

int res=0;
for(int k=1; k<=2*n; k++){

    int l=k-n, r=n, mid=(l+r)>>1ll;
    while(l<r){
        mid=(l+r)>>1ll;
        if(((k-mid)>=1 ) && (mid>=1) && (mid<=n) && ((k-mid)<=(n) ) && (s2[n-(k-mid)+1]>=s1[n-(mid)+1]) ){
            l=mid+1;
        }
        else{
            r=mid;
        }
        mid=(l+r)>>1ll;
    }



    if( ((k-mid)<=n) && (((k-mid)>=1)) && ((mid)<=n) && ((mid)>=1)  ){
        res=max(res, min(s2[n-(k-mid)+1],s1[n-(mid)+1])-q*k  );
    }
    mid--;

    if( ((k-mid)<=n) && (((k-mid)>=1)) && ((mid)<=n) && ((mid)>=1)  ){
        res=max(res, min(s2[n-(k-mid)+1],s1[n-(mid)+1])-q*k  );
    }

    mid+=2;
    if( ((k-mid)<=n) && (((k-mid)>=1)) && ((mid)<=n) && ((mid)>=1)  ){
        res=max(res, min(s2[n-(k-mid)+1],s1[n-(mid)+1])-q*k  );
    }

}
//cout<<res<<"\n";


for(int k=1; k<=2*n; k++){

    int l=k-n, r=n, mid=(l+r)>>1ll;
    while(l<r){
        mid=(l+r)>>1ll;
        if(((k-mid)>=1 ) && (mid>=1) && (mid<=n) && ((k-mid)<=(n) ) && (s1[n-(k-mid)+1]>=s2[n-(mid)+1]) ){
            l=mid+1;
        }
        else{
            r=mid;
        }
        mid=(l+r)>>1ll;
    }



    if( ((k-mid)<=n) && (((k-mid)>=1)) && ((mid)<=n) && ((mid)>=1)  ){
        res=max(res, min(s1[n-(k-mid)+1],s2[n-(mid)+1])-q*k  );
    }
    mid--;

    if( ((k-mid)<=n) && (((k-mid)>=1)) && ((mid)<=n) && ((mid)>=1)  ){
        res=max(res, min(s1[n-(k-mid)+1],s2[n-(mid)+1])-q*k  );
    }

    mid+=2;
    if( ((k-mid)<=n) && (((k-mid)>=1)) && ((mid)<=n) && ((mid)>=1)  ){
        res=max(res, min(s1[n-(k-mid)+1],s2[n-(mid)+1])-q*k  );
    }

}


long double a=res, b=q;
cout<<fixed<<setprecision(4)<<a/b;

return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 2 ms 492 KB Output is correct
17 Correct 159 ms 15980 KB Output is correct
18 Correct 157 ms 15976 KB Output is correct
19 Correct 162 ms 15980 KB Output is correct
20 Correct 160 ms 16108 KB Output is correct
21 Correct 178 ms 15980 KB Output is correct
22 Correct 155 ms 16108 KB Output is correct
23 Correct 155 ms 15980 KB Output is correct
24 Correct 157 ms 16236 KB Output is correct
25 Correct 158 ms 15980 KB Output is correct
26 Correct 161 ms 15980 KB Output is correct