#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin() , (x).end()
const ll MOD = 998244353;
const long double EPS = 0.000000001;
const double PI = 3.14159265358979323846;
const int nx[4]={0, 0, 1, -1}, ny[4]={1, -1, 0, 0};
int32_t main()
{
ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
ll n; cin>>n; vector<ld>a(n), b(n);
for(int l=0;l<n;l++) cin>>a[l]>>b[l];
sort(all(a)); sort(all(b));
reverse(all(a)); reverse(all(b));
vector<ld>head(n), tail(n);
head[0]=a[0], tail[0]=b[0];
for(int l=1;l<n;l++) head[l]=head[l-1]+a[l], tail[l]=tail[l-1]+b[l];
int l=0, r=0; ld ans=0.0;
while(l<n&&r<n) {
ld x=head[l]-l-r-2;
ld y=tail[r]-l-r-2;
ans=max(ans, min(x, y));
if(x<y) l++;
else r++;
}
cout<<setprecision(4)<<fixed<<ans<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
324 KB |
Output is correct |
17 |
Correct |
106 ms |
7912 KB |
Output is correct |
18 |
Correct |
106 ms |
7880 KB |
Output is correct |
19 |
Correct |
109 ms |
7884 KB |
Output is correct |
20 |
Correct |
106 ms |
7876 KB |
Output is correct |
21 |
Correct |
114 ms |
8312 KB |
Output is correct |
22 |
Correct |
108 ms |
7920 KB |
Output is correct |
23 |
Correct |
107 ms |
7908 KB |
Output is correct |
24 |
Correct |
121 ms |
7972 KB |
Output is correct |
25 |
Correct |
107 ms |
7876 KB |
Output is correct |
26 |
Correct |
114 ms |
8300 KB |
Output is correct |