# four numbers mock bdoi 2019 pari nai

Wed Nov 25 2020 01:54:07 GMT+0000 (UTC)

Saved by @Shami_Al #c++

```#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
ll cs=0;
struct duo
{
ld x,F,S;
};
bool sim(duo a,duo b)
{
if(a.F==b.F||a.F==b.S||a.S==b.F||a.S==b.S)
return 1;
return 0;
}
void sol()
{
cout.precision(11);
cout<<fixed;
ll n,i,k;
cin>>n;
ld a[n],vl,ans=0;
duo low[3],h[3];
for(i=0; i<3; i++)
low[i].x=INT_MAX;
for(i=0; i<n; i++)
cin>>a[i];
sort(a,a+n);
for(i=0; i<3; i++)
{
h[i].F=a[n-1-i];
h[i].S=a[n-2-i];
}
for(i=0; i<n-1; i++)
{
vl=abs(a[i]-a[i+1]);
for(k=0; k<3; k++)
{
if(vl<low[k].x)
{
ll j=k;
for(j=2; j>=k+1; j--)
{
low[j].x=low[j-1].x;
low[j].F=low[j-1].F;
low[j].S=low[j-1].S;
}
low[k].x=vl;
low[k].F=a[i];
low[k].S=a[i+1];
break;
}
}
}
for(i=0;i<3;i++)
{
for(k=0;k<3;k++)
{
if(!sim(h[i],low[k]))
ans=fmax(ans,(h[i].F+h[i].S)/low[k].x);
}
}
cout<<ans;

}
int main()
{
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
//ll t;
//cin>>t;
//while(t--)
sol();
return 0;
}
```
content_copyCOPY