Submission #411225

# Submission time Handle Problem Language Result Execution time Memory
411225 2021-05-24T18:10:14 Z LouayFarah Rice Hub (IOI11_ricehub) C++14
0 / 100
288 ms 332 KB
#include "bits/stdc++.h"
#include "ricehub.h"
using namespace std;

long long S(int X[], int h, int l, int r)
{
    long long sum = 0;
    for(int i = l; i<=r; i++)
        sum = sum + abs(h-X[i]);
    return sum;
}

int besthub(int R, int L, int X[], long long B)
{
    int res = 0;

    int r = R;
    int counter = 0;
    while(true)
    {
        int k = r/2;
        bool flag = false;
        for(int i = 0; i<=R-k; i++)
        {
            int curr = S(X, X[(2*i+k-1)/2], i, i+k-1);
            if(curr<=B)
                flag = true;
        }
        if(flag)
        {
            r++;
            counter++;
        }
        else
        {
            if(counter>0)
            {
                res = (k-1);
                break;
            }
            r = k;
        }
        cout << k << endl;
    }

    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 288 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -