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>
const int MAX_N = 100000;
int N;
double S[2][MAX_N];
inline double min(double a, double b)
{
return a < b ? a : b;
}
int main()
{
std::cin >> N;
for (int i = 0; i < N; ++i)
std::cin >> S[0][i] >> S[1][i];
std::sort(std::begin(S[0]), std::begin(S[0]) + N, std::greater<double>());
std::sort(std::begin(S[1]), std::begin(S[1]) + N, std::greater<double>());
double best = 0.0;
double a = 0.0, b = 0.0;
for (int i = 0, j = 0;;) {
if (i >= N && j >= N)
break;
else if ((i < N && a <= b) || j >= N) {
a += S[0][i] - 1.0;
b -= 1.0;
i += 1;
} else {
b += S[1][j] - 1.0;
a -= 1.0;
j += 1;
}
if (min(a, b) > best)
best = min(a, b);
}
printf("%.4lf", best);
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... |