#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
const int MAXN = 2e5+10;
const int INF = 4e18+10;
typedef pair<int,int> pii;
typedef pair<pii,int> ipii;
const int MX = 1e9+10;
int n;
vector <ld> vec, vec2;
ld pr[MAXN], pref[MAXN];
signed main(){
// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
for(int i=1; i<=n; i++){
ld x, y; cin >> x >> y;
vec.pb(x); vec2.pb(y);
}
vec.pb(INF); vec2.pb(INF);
sort(vec.rbegin(), vec.rend());
sort(vec2.rbegin(), vec2.rend());
ld ANS = 0, le = 0, ri = 0; int l=1, r=1;
for(int i=1; i<=2*n; i++){
le--; ri--;
if(r==n || le < ri){ // ambil l
le += vec[l++];
} else {
ri += vec2[r++];
}
// cout << le << ' '<< ri << " leri\n";
ANS = max(ANS, min(le, ri));
}
printf("%.4lf",(double)ANS);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |