Submission #361410

# Submission time Handle Problem Language Result Execution time Memory
361410 2021-01-29T20:11:49 Z bigDuck Sure Bet (CEOI17_sure) C++14
Compilation error
0 ms 0 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;

int32_t main(){
INIT
cin>>n;

for(int i=1; i<=n; i++){
    long double d; cin>>d;
    d=d*10000;
    a[i]=(int) d;
    //cout<<d<<"\n";
    cin>>d;
    d=d*10000;
    b[i]=(int)d;
}

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


for(int i=n; i>=1; 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++){
    auto it=sum1.lower_bound({k*10000, 0});
    if(it==sum1.end()){
        continue;
    }
    int l=1, r=n, mid=(l+r)>>1ll;
    while(l<r){
        mid=(l+r)>>1ll;
        if( ((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])-10000*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])-10000*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])-10000*k  );
    }
}
cout<<fixed<<setprecision(4)<<(long double(((long double)res)/(10000.0000) ) );

return 0;
}



Compilation message

sure.cpp: In function 'int32_t main()':
sure.cpp:75:32: error: expected primary-expression before 'long'
   75 | cout<<fixed<<setprecision(4)<<(long double(((long double)res)/(10000.0000) ) );
      |                                ^~~~
sure.cpp:75:32: error: expected ')' before 'long'
   75 | cout<<fixed<<setprecision(4)<<(long double(((long double)res)/(10000.0000) ) );
      |                               ~^~~~
      |                                )