Submission #584655

# Submission time Handle Problem Language Result Execution time Memory
584655 2022-06-27T18:38:24 Z Kanaifu Rice Hub (IOI11_ricehub) C++17
0 / 100
5 ms 1108 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int R, int L, int X[], long long B)
{
    long long prefix[100001];
    prefix[0] = X[0];
    for (int i=1; i<R; i++)
    {
        prefix[i] = prefix[i-1] + ((long long)(X[i]));
    }
    long long cost = 0;
    int leng = 1;
    long long l = 0, r = 0;
    while (r < R)
    {
        long long med = (l+r)/2;
        cost = 0;
        if (med != l)
        {
            cost += ((long long)X[med])*(med-l)-prefix[med-1];
        }
        if (med != r)
        {
            cost += prefix[r] - prefix[med] - (r-med)*((long long)X[med]);
        }
        if (cost <= B)
        {
            leng = max(leng, (int)(r - l + 1));
            r++;
        }
        else
        {
            l++;
            r++;
        }
    }
    return leng;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Incorrect 1 ms 980 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -