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 = 1e3 + 10;
pair<double, double> dp[N][N];
int main(){
int n;
cin >> n;
vector<double> a, b;
for (int i=0; i<n; i++){
double x, y;
cin >> x >> y;
a.push_back(x);
b.push_back(y);
}
sort(a.begin(), a.end(), greater<double>());
sort(b.begin(), b.end(), greater<double>());
double A = a[0] - 2;
double B = b[0] - 2;
double ans = max((double)0, min(A, B));
int p1 = 1;
int p2 = 1;
while (p1 != n || p2 != n){
if (A > B && p2 < n){
A--;
B--;
B += b[p2];
p2++;
}
else if (A <= B && p1 < n){
A--;
B--;
A += a[p1];
p1++;
}
else
break;
ans = max(ans, min(A, B));
}
printf("%.4lf", ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |