Submission #677578

# Submission time Handle Problem Language Result Execution time Memory
677578 2023-01-03T19:12:10 Z ThegeekKnight16 Rice Hub (IOI11_ricehub) C++17
0 / 100
2 ms 596 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
const int MAXN = 1e5 + 10;
long long X[MAXN], SX[MAXN];

bool Teste(int R, int L, long long B, int tam)
{
    for (int l = 1, r = tam; r <= R; l++, r++)
    {
        int m = (l + r) / 2;

        long long sum = ((m - l  + 1) * X[m]) - (SX[m] - SX[l-1]);
        sum += (SX[r] - SX[m]) - ((r - m) * SX[m]);

        if (sum <= B) return true;
    }

    return false;
}

int besthub(int R, int L, int _X[], long long B)
{
    for (int i = 1; i <= R; i++) X[i] = (long long)(_X[i-1]);
    for (int i = 1; i <= R; i++) SX[i] = X[i] + SX[i-1];

    int ini = 0; int fim = R;
    while (ini < fim)
    {
        int m = (ini + fim) / 2;
        if (ini == fim-1) m = fim;
        if (Teste(R, L, B, m)) ini = m;
        else fim = m-1;
    }

    return ini;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -