#include <bits/stdc++.h>
using namespace std;
#define double long double
#define all(x) x.begin(),x.end()
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;cin>>n;
vector<double> a(n+1),b(n+1);
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
}
a[n]=0;
b[n]=0;
sort(all(a),greater<>());
sort(all(b),greater<>());
double total1=0,total2=0;
int ptr1=0,ptr2=0;
double ans=0;
for(;ptr1<=n&&ptr2<=n;){
if(total1<total2){
total1+=a[ptr1++];
}
else{
total2+=b[ptr2++];
}
total1-=1;
total2-=1;
ans=max(min(total1,total2),ans);
}
cout<<fixed<<setprecision(4)<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
78 ms |
4724 KB |
Output is correct |
18 |
Correct |
84 ms |
4720 KB |
Output is correct |
19 |
Correct |
85 ms |
4724 KB |
Output is correct |
20 |
Correct |
80 ms |
4740 KB |
Output is correct |
21 |
Correct |
89 ms |
5196 KB |
Output is correct |
22 |
Correct |
79 ms |
4720 KB |
Output is correct |
23 |
Correct |
80 ms |
4856 KB |
Output is correct |
24 |
Correct |
86 ms |
4824 KB |
Output is correct |
25 |
Correct |
85 ms |
4824 KB |
Output is correct |
26 |
Correct |
87 ms |
5204 KB |
Output is correct |