# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
842596 | vjudge1 | Sure Bet (CEOI17_sure) | C++17 | 76 ms | 11476 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.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
double pre_a[N];
double pre_b[N];
double a[N] , b[N] , mx[N];
main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if(fopen("solve.inp" , "r")) {
freopen("solve.inp" , "r" , stdin);
freopen("solve.out" , "w" , stdout);
}
int n;
cin >> n;
for(int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
sort(a , a + n , greater <double> ());
sort(b , b + n , greater <double> ());
for(int i = 1; i <= n; i++) {
pre_a[i] = pre_a[i - 1] + a[i - 1] - 1;
pre_b[i] = pre_b[i - 1] + b[i - 1] - 1;
}
for(int i = 1; i <= n; i++) {
mx[i] = max(mx[i - 1] , pre_b[i]);
}
double l = 0.0;
double r = INT_MAX;
for(int i = 0; i < 100; i++) {
double mid = (l + r) / 2;
bool check = false;
for(int j = 0; j <= n; j++) {
int x = min(n * 1.0 , (pre_a[j] - mid));
if(x >= 0 && mx[x] >= j + mid) {
check = (check | x);
}
}
if(check == true) l = mid;
else r = mid;
}
cout << setprecision(4) << fixed << r << '\n';
return 0x0;
}
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... |