# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
361402 |
2021-01-29T18:24:20 Z |
bigDuck |
Sure Bet (CEOI17_sure) |
C++14 |
|
1 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;
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 ac1=it->ft, k1=(n-it->sc)+1;
int k2=k-k1, ac2=0;
//cout<<ac1<<" "<<ac2<<"\n";
int l=1, r=n, mid=(r+l)>>1ll;
while(l<r){
mid=(l+r)>>1ll;
if( ( (k2-mid)>=1 ) && ((k1+mid)<=n) && ( (k2-mid)<=n ) && (s1[n-(k1+mid)+1]<=s2[n-(k2-mid)+1])){
l=mid+1;
}
else{
r=mid;
}
mid=(l+r)>>1ll;
}
if( ( (k1+mid)>n ) || ( (k2-mid)<1 ) ){
mid--;
}
if( (k1+mid<=n) && (k2-mid<=n)&& (k1+mid>=1) && (k2-mid>=1) ){
ac1=s1[n-(k1+mid)+1], ac2=s2[n-(k2-mid)+1];}
res=max(res, min(ac1, ac2)-k*10000);
mid--;
if( (k1+mid<=n) && (k2-mid<=n) && (k2-mid>=1) && (k1+mid>=1) ){
ac1=s1[n-(k1+mid)+1], ac2=s2[n-(k2-mid)+1];
res=max(res, min(ac1, ac2)-k*10000);}
}
cout<<fixed<<setprecision(4)<<(res/10000.000000);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |