#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
504 KB |
Output is correct |
17 |
Correct |
84 ms |
3004 KB |
Output is correct |
18 |
Correct |
80 ms |
3524 KB |
Output is correct |
19 |
Correct |
80 ms |
3004 KB |
Output is correct |
20 |
Correct |
83 ms |
3516 KB |
Output is correct |
21 |
Correct |
92 ms |
3004 KB |
Output is correct |
22 |
Correct |
85 ms |
3004 KB |
Output is correct |
23 |
Correct |
81 ms |
3508 KB |
Output is correct |
24 |
Correct |
83 ms |
3508 KB |
Output is correct |
25 |
Correct |
80 ms |
3508 KB |
Output is correct |
26 |
Correct |
88 ms |
3764 KB |
Output is correct |