#define DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)
#ifdef DEBUG
#define DBG(...) __VA_ARGS__
#else
#define DBG(...)
#endif
const int MAXN = 1e5+5;
int N;
int A[MAXN]; ll B[MAXN];
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N;
FOR(i,1,N){
double a, b; cin >> a >> b;
A[i] = (int)round(a*10000), B[i] = (ll)round(b*10000);
A[i] -= 10000, B[i] -= 10000;
}
sort(A+1,A+1+N,greater<int>());
sort(B+1,B+1+N,greater<ll>());
FOR(i,1,N) B[i] += B[i-1];
ll ans = 0, x = 0;
FOR(i,0,N) {
x += A[i];
int lo = 0, hi = N+1;
while (lo < hi) {
int mid = (lo+hi)/2;
if (x-mid*10000 >= B[mid]-i*10000) lo = mid+1;
else hi = mid;
}
int idx = lo-1;
//cout << i << " :: idx " << idx << " x y " << x-idx*10000 << " " << B[idx]-i*10000 << endl;
ans = max(ans, min(x-idx*10000, B[idx]-i*10000));
//if (idx+1 <= N) cout << i << " :: idx " << idx << " x y " << x-(idx+1)*10000 << " " << B[idx+1]-i*10000 << endl;
if (idx+1 <= N) ans = max(ans, min(x-(idx+1)*10000, B[idx+1]-i*10000));
}
cout << fixed << setprecision(4) << (double)ans/10000 << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
380 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
380 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 |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
380 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
380 KB |
Output is correct |
17 |
Correct |
105 ms |
2936 KB |
Output is correct |
18 |
Correct |
105 ms |
2952 KB |
Output is correct |
19 |
Correct |
106 ms |
2936 KB |
Output is correct |
20 |
Correct |
106 ms |
3064 KB |
Output is correct |
21 |
Correct |
113 ms |
3292 KB |
Output is correct |
22 |
Correct |
105 ms |
2956 KB |
Output is correct |
23 |
Correct |
105 ms |
2936 KB |
Output is correct |
24 |
Correct |
106 ms |
2808 KB |
Output is correct |
25 |
Correct |
107 ms |
2808 KB |
Output is correct |
26 |
Correct |
112 ms |
3320 KB |
Output is correct |