#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
typedef long long ll;
const int E = 1e6+777;
const long long inf = 1e18+777;
const int N = 1e5+777;
const int MOD = 1e9+7;
const bool I = 1;
int n, color[N], v1[N], sum1;
double a[N], b[N], pref[3][N];
double F(int x, int y){
return (double)min(pref[1][x] - (x + y), pref[2][y] - (x + y));
}
double get(double res = 0.0){
for(int i = 1; i <= n; ++i){
int L = 2, R = n, o = 1;
while(L <= R){
int M = (L + R) >> 1;
if(F(i, M-1) <= F(i, M+1)){
L = (o = M) + 1;
}else R = M - 1;
}
res = max(res, F(i, o));
}
for(int i = 1; i <= n; ++i){
int L = 2, R = n, o = 1;
while(L <= R){
int M = (L + R) >> 1;
if(F(M-1, i) <= F(M, i)){
L = (o = M) + 1;
}else R = M - 1;
}
res = max(res, F(o, i));
}
return res;
}
int main(){
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> a[i] >> b[i];
}
sort(a+1,a+1+n), reverse(a+1,a+1+n);
sort(b+1,b+1+n), reverse(b+1,b+1+n);
for(int i = 1; i <= n; ++i){
pref[1][i] = pref[1][i-1] + a[i];
pref[2][i] = pref[2][i-1] + b[i];
}
cout << fixed << setprecision(4) << get() << '\n';
};
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
138 ms |
3392 KB |
Output is correct |
18 |
Correct |
161 ms |
3396 KB |
Output is correct |
19 |
Correct |
142 ms |
3528 KB |
Output is correct |
20 |
Correct |
140 ms |
3316 KB |
Output is correct |
21 |
Correct |
155 ms |
3396 KB |
Output is correct |
22 |
Correct |
138 ms |
3404 KB |
Output is correct |
23 |
Correct |
142 ms |
3396 KB |
Output is correct |
24 |
Correct |
139 ms |
3424 KB |
Output is correct |
25 |
Correct |
157 ms |
3400 KB |
Output is correct |
26 |
Correct |
157 ms |
3432 KB |
Output is correct |