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;
#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
const int MAXN = 100005;
double a[MAXN], b[MAXN];
int nArr;
void process(void) {
cin >> nArr;
for (int i = 1; i <= nArr; ++i)
cin >> a[i] >> b[i];
sort(a + 1, a + nArr + 1);
sort(b + 1, b + nArr + 1);
double res(0), sumA(0), sumB(0);
int i(nArr), j(nArr);
while(max(i, j) > 0) {
if(i > 0 && sumA <= sumB) {
sumA += a[i--];
} else {
sumB += b[j--];
}
res = max(res, min(sumA, sumB) - 2 * nArr + i + j);
}
cout << setprecision(4) << fixed << res << '\n';
}
int main(void) {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
process();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |