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>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 101010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
ll A[MAX];
ll B[MAX];
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int N;
cin >> N;
int i;
double a, b;
for (i = 1; i <= N; i++) {
cin >> a >> b;
A[i] = a * 10000;
B[i] = b * 10000;
}
sort(A + 1, A + N + 1);
sort(B + 1, B + N + 1);
ll sa, sb;
int pa, pb;
pa = pb = N;
ll ans = 0;
sa = sb = 0;
for (i = 1; i <= 2 * N; i++) {
if ((sa < sb && pa) || !pb) {
sa += A[pa];
pa--;
}
else {
sb += B[pb];
pb--;
}
ans = max(ans, min(sa, sb) - 1ll * i * 10000);
}
cout << fixed;
cout.precision(4);
cout << (double)ans / 10000. << ln;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |