#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pf push_front
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
void boost(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
return;
}
void solve(){
int n;
cin>>n;
ld a[n],b[n];
for(int i=0; i<n; i++) cin>>a[i]>>b[i];
sort(a,a+n,greater<double>());
sort(b,b+n,greater<double>());
ld ans=0;
int p1=1,p2=1;
ld cnt1=1,cnt2=1;
ld suma=a[0],sumb=b[0];
while(p1<n||p2<n){
if(p1==n||p2==n){
if(p1==n){
sumb+=b[p2];
p2++;
cnt2++;
}
else{
suma+=a[p1];
p1++;
cnt1++;
}
}
else{
if(suma>sumb){
sumb+=b[p2];
p2++;
cnt2++;
}
else{
suma+=a[p1];
p1++;
cnt1++;
}
}
ans=max(ans,min(suma,sumb)-cnt1-cnt2);
}
cout<<setprecision(4)<<ans;
return;
}
int main(){
boost();
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |