Submission #60704

# Submission time Handle Problem Language Result Execution time Memory
60704 2018-07-24T14:40:11 Z theknife2001 Rice Hub (IOI11_ricehub) C++17
17 / 100
40 ms 3408 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;
const int N=1e5+55;
long long sum[N];
int pos[N];
int n;



bool ok(int x, long long b)
{
    long long best,cur;
    best=1e9+55;
    for(int i=0;i<=n-x;i++)
    {
        cur=pos[x/2+i]*(x/2)-sum[i+x/2-1];
        if(i)
            cur+=sum[i-1];
        cur+=sum[i+x-1]-sum[i+(x-1)/2]-pos[x/2+i]*(x/2);
        best=min(best,cur);
    }
    if(best>b)
        return 0;
    return 1;
}

int besthub(int N, int L, int X[], long long B)
{
    n=N;
    for(int i=0;i<n;i++)
    {
        pos[i]=X[i];
        sum[i]=X[i];
        if(i)
            sum[i]+=sum[i-1];
    }
    int l=2;
    int r=n;
    int mid;
    while(l<r)
    {
        mid=(l+r)/2;
        if(ok(mid,B))
            l=mid+1;
        else
            r=mid;
    }
    return l-1;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 532 KB Output is correct
3 Correct 3 ms 552 KB Output is correct
4 Correct 1 ms 552 KB Output is correct
5 Correct 3 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 552 KB Output is correct
2 Correct 3 ms 552 KB Output is correct
3 Incorrect 3 ms 552 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 612 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Incorrect 3 ms 688 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 956 KB Output is correct
2 Correct 8 ms 1080 KB Output is correct
3 Incorrect 40 ms 3408 KB Output isn't correct
4 Halted 0 ms 0 KB -