#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
typedef tree<pii ,null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const ll MAXN = 301;
const ll MOD = 1e9+7;
const ll INF = 1e6+10;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n,i,x,y;
double sx,sy,ans=0;
cin>>n;
double a[n],b[n];
for(i=0;i<n;i++){
cin>>a[i]>>b[i];
}
sort(a,a+n,greater<double>());
sort(b,b+n,greater<double>());
x=0; y=0; sx=0; sy=0;
for(i=0;i<2*n;i++){
if(sx<=sy && x!=n){
sx+=a[x];
x++;
}else{
sy+=b[y];
y++;
}
//cout<<x<<" "<<y<<" "<<sx<<" "<<sy<<" "<<(double)(min(sx,sy)-(double)(x+y))<<endl;
ans = max(ans, (double)(min(sx,sy)-(double)(x+y)) );
}
//cout<<setprecision(5)<<ans<<endl;
printf("%.4lf",(double)ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |