Submission #739573

# Submission time Handle Problem Language Result Execution time Memory
739573 2023-05-10T16:45:33 Z alexdd Seesaw (JOI22_seesaw) C++17
1 / 100
54 ms 324 KB
#include<bits/stdc++.h>
using namespace std;
#define double long double
int n;
int a[200005];
double tot,ans=1000000000;
double verif(double le)///lungimea minima daca barycentrul nu poate trece in stanga lui le
{
    double sum = tot,mxm;
    int pozs=1,pozd=n;
    mxm = tot/n;
    for(int i=1;i<=n-1;i++)
    {
        if((sum-a[pozd])/(n-i)>=le)
        {
            sum-=a[pozd];
            pozd--;
        }
        else
        {
            sum-=a[pozs];
            pozs++;
        }
        mxm = max(mxm, sum/(n-i));
    }
    ans = min(ans, mxm-le);
    return mxm-le;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        tot+=a[i];
    }
    double st,dr,mij1,mij2;
    st=0;
    dr=tot/n;
    for(int i=0;i<2000;i++)
    {
        mij1 = st + (dr-st)/3;
        mij2 = mij1 + (dr-st)/3;
        if(verif(mij1)<verif(mij2))
            dr=mij2;
        else
            st=mij1;
    }
    int buc = 100000;
    for(int i=0;i<=buc;i++)
    {
        ans = min(ans, verif(st+((dr-st)/buc)*i));
    }
    cout<<fixed<<setprecision(15)<<ans;
    return 0;
}
/**



*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 11 ms 324 KB Output is correct
3 Correct 11 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 11 ms 324 KB Output is correct
3 Correct 11 ms 212 KB Output is correct
4 Incorrect 54 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 11 ms 324 KB Output is correct
3 Correct 11 ms 212 KB Output is correct
4 Incorrect 54 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 11 ms 324 KB Output is correct
3 Correct 11 ms 212 KB Output is correct
4 Incorrect 54 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -