Submission #361525

# Submission time Handle Problem Language Result Execution time Memory
361525 2021-01-30T11:55:20 Z bigDuck Sure Bet (CEOI17_sure) C++14
20 / 100
2 ms 492 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";
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 384 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 384 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 Incorrect 2 ms 492 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 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 384 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 Incorrect 2 ms 492 KB Output isn't correct
13 Halted 0 ms 0 KB -