#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define int long long
const int N = 2e5;
const int mod = 1e9 + 7;
signed main(){
int n; cin >> n;
vector<long double> a(n), b(n);
for(int i = 0;i < n; i++){
cin >> a[i] >> b[i];
}
long double ans = 0.0;
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
long double s = 0, s1 = 0;
int cnt = 0, i =0 ;
for(int j = 0;j < n; j++){
s1+= b[j];
cnt++;
ans = max(ans, min(s, s1) - cnt);
while(i < n && s - cnt <= s1-cnt){
s+= a[i];
i++, cnt++;
ans = max(ans, min(s, s1) - cnt);
}
}
printf("%.4lf", (double)ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
105 ms |
3420 KB |
Output is correct |
18 |
Correct |
105 ms |
3416 KB |
Output is correct |
19 |
Correct |
104 ms |
3564 KB |
Output is correct |
20 |
Correct |
108 ms |
3560 KB |
Output is correct |
21 |
Correct |
115 ms |
3556 KB |
Output is correct |
22 |
Correct |
103 ms |
3672 KB |
Output is correct |
23 |
Correct |
104 ms |
3564 KB |
Output is correct |
24 |
Correct |
105 ms |
3556 KB |
Output is correct |
25 |
Correct |
106 ms |
3560 KB |
Output is correct |
26 |
Correct |
120 ms |
3568 KB |
Output is correct |