Submission #345367

# Submission time Handle Problem Language Result Execution time Memory
345367 2021-01-07T08:01:53 Z daniel920712 Rice Hub (IOI11_ricehub) C++14
0 / 100
4 ms 1004 KB
#include "ricehub.h"
#include <algorithm>
#include <vector>
using namespace std;
vector < long long > all;
long long X[100005];
int besthub(int R, int L, int ttt[], long long B)
{
    long long tt=0,t,x,y,i,l,r,ans=0;
    all.push_back(0);
    for(i=1;i<=R;i++)
    {
        all.push_back((long long) ttt[i-1]);
        all[i]+=all[i-1];
        X[i]=(long long) ttt[i-1];
    }
    for(i=1;i<=R;i++)
    {
        l=0;
        r=R+1;
        while((r-l)>1)
        {

            t=(r-l-1)/2;
            if(i+t>R||i-t<1) break;
            tt=(all[i+t]-all[i])-X[i]*t;
            tt+=X[i]*t-(all[i-1]-all[i-t]);

            if((r-l+1)%2==0)
            {
                if(i+t>R&&i-t<1) break;
                x=2e9;
                y=2e9;
                if(i+t<=R) x=X[i+t+1]-X[i];
                if(i-t>=1) y=X[i]-X[i-t];
                tt+=min(x,y);

            }
            if(tt<=B) l=(l+r)/2;
            else r=(l+r)/2;

        }
        ans=max(ans,l);
    }
    return (int) ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1004 KB Output isn't correct
2 Halted 0 ms 0 KB -