#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n;
double a[MAXN], b[MAXN];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
double ans = 0;
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i];
}
sort(a + 1, a + n + 1, greater <double>());
sort(b + 1, b + n + 1, greater <double>());
int pt = 0;
double oa = 0, ob = 0, cur = 0;
for(int i = 0; i <= n; i++)
{
oa += a[i];
while(pt + 1 <= n and ob + b[pt + 1] < oa)
{
pt++;
ob += b[pt];
cur = max(cur, ob - pt);
}
ans = max(ans, cur - i);
if(pt + 1 <= n)
{
ans = max(ans, oa - pt - 1 - i);
}
}
cout << setprecision(4) << fixed << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
67 ms |
3140 KB |
Output is correct |
18 |
Correct |
77 ms |
3216 KB |
Output is correct |
19 |
Correct |
76 ms |
3196 KB |
Output is correct |
20 |
Correct |
66 ms |
3168 KB |
Output is correct |
21 |
Correct |
72 ms |
3704 KB |
Output is correct |
22 |
Correct |
73 ms |
3204 KB |
Output is correct |
23 |
Correct |
72 ms |
3152 KB |
Output is correct |
24 |
Correct |
66 ms |
3184 KB |
Output is correct |
25 |
Correct |
66 ms |
3116 KB |
Output is correct |
26 |
Correct |
72 ms |
3600 KB |
Output is correct |