# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151213 | karma | Sure Bet (CEOI17_sure) | C++14 | 155 ms | 5268 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>
#define ld long double
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int N = int(1e5) + 1;
const ld eps = 1e-6;
int n;
ld a[N], b[N], res = 0, cur;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen("test.inp", "r")) {
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i] >> b[i];
sort(a + 1, a + n + 1, greater<ld>()), sort(b + 1, b + n + 1, greater<ld>());
for(int i = 1; i <= n; ++i) a[i] += a[i - 1], b[i] += b[i - 1];
int low, high, mid; ld x, x1;
for(int i = 1; i <= n; ++i) {
low = 1, high = n;
cur = min(a[i] - i - 1, b[1] - i - 1);
while(low <= high) {
mid = (low + high) >> 1;
x = min(a[i] - i - mid, b[mid] - i - mid);
x1 = min(a[i] - i - mid + 1, b[mid - 1] - i - mid + 1);
cur = max({cur, x, x1});
if(x >= x1) low = mid + 1;
else high = mid - 1;
}
res = max(res, cur);
}
cout << fixed << setprecision(4) << res;
}
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... |