This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;
vector<double> a,b,c,d;
int TS(int x,int l,int r){
if(l==r)return l;
int ml=l+(r-l)/3;
int mr=r-(r-l)/3;
int p=min(c[x]-ml-1,d[ml]-x-1);
int q=min(c[x]-mr-1,c[mr]-x-1);
if(p<=q)return TS(x,ml+1,r);
else return TS(x,l,mr-1);
}
int main() {
int n;cin>>n;
a.resize(n);b.resize(n);c.resize(n);d.resize(n);
REP(i,0,n)cin>>a[i]>>b[i];
sort(a.begin(),a.end());
sort(b.begin(),b.end());
reverse(a.begin(),a.end());
reverse(b.begin(),b.end());
double ans=0;
c[0]=a[0]-1;
REP(i,1,n)c[i]=a[i]+c[i-1]-1;
d[0]=b[0]-1;
REP(i,1,n)d[i]=b[i]+d[i-1]-1;
REP(i,0,n){
int k=TS(i,0,n-1);
ans=max(ans,min(c[i]-k-1,d[k]-i-1));
}
REP(i,0,n)REP(j,0,n)ans=max(ans,min(c[i]-j-1,d[j]-i-1));
cout<<fixed<<setprecision(4)<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |