#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST freopen("in.txt","r",stdin);
#define ab(a) ((a < 0) ? (-(a)) : (a))
#define all(a) a.begin(), a.end()
int main(){
fastIO;
int n;
cin >> n;
db a[n];
db b[n];
for(int i = 0;i < n; i++ ){
cin >> a[i] >> b[i];
a[i] -- ;
b[i] -- ;
}
sort(a, a + n);
sort(b, b + n);
reverse(a, a + n);
reverse(b, b + n);
db sum1 = 0;int cnt1 = 0;
db sum2 = 0;int cnt2 = 0;
db ans = 0;
for(int i = 0;i < n;i ++ ){
sum1 += a[i];
cnt1 ++ ;
ans = max(ans, min(sum1-cnt2,sum2-cnt1));
while(sum1-cnt2 > sum2-cnt1 and cnt2 < n){
sum2 += b[cnt2];
cnt2++;
ans = max(ans, min(sum1-cnt2,sum2-cnt1));
}
ans = max(ans, min(sum1-cnt2,sum2-cnt1));
}
cout << fixed << setprecision(4) << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
568 KB |
Output is correct |
6 |
Correct |
2 ms |
572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
568 KB |
Output is correct |
6 |
Correct |
2 ms |
572 KB |
Output is correct |
7 |
Correct |
2 ms |
576 KB |
Output is correct |
8 |
Correct |
3 ms |
636 KB |
Output is correct |
9 |
Correct |
3 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
668 KB |
Output is correct |
12 |
Correct |
3 ms |
672 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
3 ms |
768 KB |
Output is correct |
15 |
Correct |
4 ms |
816 KB |
Output is correct |
16 |
Correct |
4 ms |
816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
532 KB |
Output is correct |
5 |
Correct |
2 ms |
568 KB |
Output is correct |
6 |
Correct |
2 ms |
572 KB |
Output is correct |
7 |
Correct |
2 ms |
576 KB |
Output is correct |
8 |
Correct |
3 ms |
636 KB |
Output is correct |
9 |
Correct |
3 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
668 KB |
Output is correct |
12 |
Correct |
3 ms |
672 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
3 ms |
768 KB |
Output is correct |
15 |
Correct |
4 ms |
816 KB |
Output is correct |
16 |
Correct |
4 ms |
816 KB |
Output is correct |
17 |
Correct |
98 ms |
3780 KB |
Output is correct |
18 |
Correct |
124 ms |
5164 KB |
Output is correct |
19 |
Correct |
100 ms |
6420 KB |
Output is correct |
20 |
Correct |
102 ms |
7932 KB |
Output is correct |
21 |
Correct |
108 ms |
9540 KB |
Output is correct |
22 |
Correct |
100 ms |
11028 KB |
Output is correct |
23 |
Correct |
100 ms |
12400 KB |
Output is correct |
24 |
Correct |
103 ms |
13728 KB |
Output is correct |
25 |
Correct |
101 ms |
15132 KB |
Output is correct |
26 |
Correct |
109 ms |
16984 KB |
Output is correct |