#include <iostream>
#include <algorithm>
#include <iomanip>
#define MAX 100000
using namespace std;
///ifstream cin ("c.in");
///ofstream cout ("c.out");
double a[MAX + 10], b[MAX + 10];
bool cmp(double x, double y)
{
return (x > y);
}
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
sort(a + 1, a + n + 1, cmp);
sort(b + 1, b + n + 1, cmp);
int nA = 1, nB = 1;
double A = 0, B = 0, ans = 0;
for (int i = 1; i <= 2 * n; i++)
{
if (nA <= n && (nB == n + 1 || A < B))
{
A = A + a[nA];
nA++;
}
else
{
B = B + b[nB];
nB++;
}
ans = max(ans, min(A, B) - i);
}
cout << fixed << setprecision(4) << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
312 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
320 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
316 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
312 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
320 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
316 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
134 ms |
3140 KB |
Output is correct |
18 |
Correct |
124 ms |
3120 KB |
Output is correct |
19 |
Correct |
125 ms |
3152 KB |
Output is correct |
20 |
Correct |
152 ms |
3212 KB |
Output is correct |
21 |
Correct |
144 ms |
3476 KB |
Output is correct |
22 |
Correct |
123 ms |
3152 KB |
Output is correct |
23 |
Correct |
128 ms |
3152 KB |
Output is correct |
24 |
Correct |
130 ms |
3272 KB |
Output is correct |
25 |
Correct |
129 ms |
3096 KB |
Output is correct |
26 |
Correct |
184 ms |
3668 KB |
Output is correct |