Submission #924834

# Submission time Handle Problem Language Result Execution time Memory
924834 2024-02-09T20:12:33 Z Lam_lai_cuoc_doi Rice Hub (IOI11_ricehub) C++17
100 / 100
25 ms 28564 KB
#include "ricehub.h"

using ll = long long;

bool Check(int num, int R, int L, int X[], long long B) {
  ll *a = new ll[R + 1];
  ll *s = new ll[R + 1];
  for (int i = 1; i <= R; ++i) {
    a[i] = X[i - 1];
    s[i] = s[i - 1] + a[i];
  }

  for (int i = 1; i <= R - num + 1; ++i) {
    int mid = (i + (i + num - 1)) / 2;

    if ((s[i + num - 1] - s[mid]) - (i + num - 1 - mid) * a[mid] + (mid - i + 1) * a[mid] - (s[mid] - s[i - 1]) <= B) {
      return true;
    }
  }

  return false;
}

int besthub(int R, int L, int X[], long long B)
{
  int l = 1, m, h = R;
  while (l <= h) {
    m = (l + h) / 2;
    if (Check(m, R, L, X, B)) {
      l = m + 1;
    } else {
      h = m - 1;
    }
  }

  return h;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 1220 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 1 ms 1372 KB Output is correct
24 Correct 1 ms 1372 KB Output is correct
25 Correct 1 ms 1372 KB Output is correct
26 Correct 1 ms 1372 KB Output is correct
27 Correct 1 ms 1372 KB Output is correct
28 Correct 1 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4956 KB Output is correct
2 Correct 4 ms 4956 KB Output is correct
3 Correct 23 ms 28564 KB Output is correct
4 Correct 24 ms 28416 KB Output is correct
5 Correct 12 ms 13516 KB Output is correct
6 Correct 11 ms 12632 KB Output is correct
7 Correct 21 ms 28156 KB Output is correct
8 Correct 22 ms 28080 KB Output is correct
9 Correct 11 ms 13404 KB Output is correct
10 Correct 11 ms 13284 KB Output is correct
11 Correct 24 ms 28496 KB Output is correct
12 Correct 23 ms 28420 KB Output is correct
13 Correct 12 ms 13404 KB Output is correct
14 Correct 12 ms 12636 KB Output is correct
15 Correct 18 ms 21336 KB Output is correct
16 Correct 17 ms 21340 KB Output is correct
17 Correct 20 ms 25436 KB Output is correct
18 Correct 22 ms 25436 KB Output is correct
19 Correct 25 ms 26964 KB Output is correct
20 Correct 21 ms 26960 KB Output is correct