# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
866748 | nghia0912 | Sure Bet (CEOI17_sure) | C++17 | 102 ms | 5304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define COPYRIGHT CODE BY TRINH TUAN NGHIA
#include<bits/stdc++.h>
#define Boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define endl "\n"
#define st first
#define nd second
#define ii pair <ll,ll>
#define iii pair <ll,ii>
#define iiii pair <ii,ii>
#define pb push_back
#define NAME "bet"
using namespace std;
const ll N = 1e5 + 10;
int n;
double a[N], b[N];
double sa[N], sb[N];
double ans = 0;
void inp (){
cin >> n;
for (int i =1 ; i <= n; ++i){
cin >> a[i] >> b[i];
}
sort(a + 1, a + n + 1, greater<double>());
sort(b + 1, b + n + 1, greater<double>());
for (int i = 1; i <= n; ++i){
sa[i] = sa[i - 1] + a[i];
sb[i] = sb[i - 1] + b[i];
//cout <<a[i] << " " << sa[i] << endl;
}
}
void solve(){
double l = 0, r = 1e9 +7;
for (int i = 1; i <= 60; ++i){
double mid = (l + r) / 2;
bool check = false;
double temp = 0, temp2 = 0;
int pos = 0, pos2 = 0;
for (int j = 0;j <= 2 * n; ++j){
while (temp - j < mid and pos < n){
temp = sa[++pos];
}
while (temp2 - j < mid and pos2 < n){
temp2 = sb[++pos2];
}
if (pos + pos2 <= j and temp - j >= mid and temp2 - j >= mid){
//if (mid == 9,4)cout << temp << endl;
check = true;
}
}
if (check){
l = mid;
ans = max(ans, mid);
}
else r = mid;
//cout << mid << endl;
}
cout << setprecision(4) << fixed << ans << endl;
}
signed main (){
if (fopen(NAME".inp", "r")){
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
Boost;
inp();
solve();
}
/*
input
*/
/*
output
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |