답안 #739719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739719 2023-05-11T06:41:56 Z alexdd Seesaw (JOI22_seesaw) C++17
34 / 100
314 ms 33348 KB
#include<bits/stdc++.h>
using namespace std;
//ifstream fin("seesaw.in");
//#define cin fin
#define double long double
vector<double> ord;
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;
    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));
        //cout<<fixed<<setprecision(15)<<sum/(n-i)<<"\n";
    }
    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];
    }
    for(int i=1;i<=n;i++)
    {
        double cv = 0;
        for(int j=i;j<=n;j++)
        {
            cv += a[j];
            ord.push_back(cv/(j-i+1));
        }
    }
    sort(ord.begin(),ord.end());
    while(ord[ord.size()-1]>tot/n)
        ord.pop_back();
    int st,dr,mij1,mij2;
    st=0;
    dr=ord.size()-1;
    while(dr-st+1>=1000)
    {
        mij1 = st + (dr-st+1)/3;
        mij2 = mij1 + (dr-st+1)/3;
        if(verif(ord[mij1])<verif(ord[mij2]))
            dr=mij2;
        else
            st=mij1;
    }
    //st=0;dr=ord.size()-1;
    for(int i=st;i<=dr;i++)
        ans = min(ans, verif(ord[i]));
    cout<<fixed<<setprecision(15)<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 298 ms 33220 KB Output is correct
9 Correct 295 ms 33348 KB Output is correct
10 Correct 314 ms 33344 KB Output is correct
11 Incorrect 302 ms 33308 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 298 ms 33220 KB Output is correct
9 Correct 295 ms 33348 KB Output is correct
10 Correct 314 ms 33344 KB Output is correct
11 Incorrect 302 ms 33308 KB Output isn't correct
12 Halted 0 ms 0 KB -