/*input
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5 + 100;
const int mod=1e9 + 7;
#define int long long
const int inf=1e18;
#define pii pair<int, int>
#define f first
#define s second
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl
//Trace prints the name of the variable and the value.
double a[N], b[N];int n;
bool sf(double f, double s)
{
return f>s;
}
bool p(double x)
{
// cout<<x<<": ";
for(int i=1;i<=n;i++)
{
int temp=a[i]-i-x;double ti=i+0.0;
// cout<<i<<" "<<temp<<endl;
if(temp>0&&b[temp]-ti-temp>=x) return 1;
}
return 0;
}
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
double low=0.000, high=3e8;
high=1;
sort(a+1, a+n+1, sf);sort(b+1, b+n+1, sf);
for(int i=2;i<=n;i++) {a[i]+=a[i-1];b[i]+=b[i-1];}
// for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
// for(int i=1;i<=n;i++) cout<<b[i]<<" ";cout<<endl;
while(high-low>1e-8)
{
double mid=(low+high)/2;
if(p(mid)) low=mid;
else high=mid;
// cout<<endl<<endl;
}
cout<<fixed<<setprecision(4)<<low;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |