/*Lazy propagation 21
*
*
* Imansoska228
* Imancrush
* Imantopchik
* .*n*.
* Author: Imansoska
* Slishkom slab
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FF first
#define SS second
#define pb push_back
#define bp pop_back()
#define pf push_front
#define int long long
#define Imansoska ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl cout << "\n"
//#define input cin
//#define print cout
const int N = 1e5 + 13 ;
const int maxn= 1e6+100;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int ima = 1e4 + 10;
int n;
double z[100010] , s[100010];
double g1 , g2;
signed main (/*Imansoska*/) {
Imansoska
// freopen("lepus.in","r",stdin);
// freopen("lepus.out","w",stdout);
cin >> n;
for ( int i=1; i<=n; i++ ) {
cin >> z[i] >> s[i];
}
sort( z+1 , z+1+n );
sort( s+1 , s+1+n );
int l=1 , r=1 ;
double mx=-9999;
g1=z[n]-2;
g2=s[n]-2;
mx=max(mx , min(g1,g2));
for ( int i=1; i<=n*2; i++ ) {
mx=max(mx , min(g1 , g2));
if ( g1<g2 ) {
g1+=z[n-l]-1;
g2-=1;
l++;
}
mx=max(mx , min(g1 , g2));
if ( g2<g1 ) {
g2+=s[n-r]-1;
r++;
g1-=1;
}
mx=max(mx , min(g1 , g2));
}
mx=max(mx , 0.0);
printf("%.4lf",(double)mx);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |