Submission #891803

# Submission time Handle Problem Language Result Execution time Memory
891803 2023-12-24T05:05:31 Z ind1v Rice Hub (IOI11_ricehub) C++11
100 / 100
15 ms 3676 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;

const int R = 1e5 + 5;

int xx[R];
long long s[R];

long long sum(int i, int j) {
  if (i > j) {
    return 0;
  }
  return (i == 0 ? s[j] : s[j] - s[i - 1]);
}

long long cost(int i, int j) {
  int mid = (i + j) >> 1;
  long long res = 0;
  res += 1LL * xx[mid] * (mid - i + 1) - sum(i, mid);
  if (mid + 1 <= j) {
    res += sum(mid + 1, j) - 1LL * xx[mid] * (j - mid);
  }
  return res;
}

int besthub(int r, int l, int x[], long long b) {
  for (int i = 0; i < r; i++) {
    s[i] = (i == 0 ? x[i] : x[i] + s[i - 1]);
    xx[i] = x[i];
  }
  int ans = 0;
  for (int i = 0, j = 0; i < r; i++) {
    while (j + 1 <= i && cost(j, i) > b) {
      j++;
    }
    ans = max(ans, i - j + 1);
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2496 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2496 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2648 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2496 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2492 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2500 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 9 ms 3676 KB Output is correct
4 Correct 9 ms 3676 KB Output is correct
5 Correct 5 ms 2992 KB Output is correct
6 Correct 5 ms 2908 KB Output is correct
7 Correct 9 ms 3420 KB Output is correct
8 Correct 8 ms 3384 KB Output is correct
9 Correct 4 ms 2904 KB Output is correct
10 Correct 5 ms 2908 KB Output is correct
11 Correct 10 ms 3672 KB Output is correct
12 Correct 11 ms 3676 KB Output is correct
13 Correct 6 ms 2908 KB Output is correct
14 Correct 5 ms 2908 KB Output is correct
15 Correct 7 ms 3280 KB Output is correct
16 Correct 7 ms 3420 KB Output is correct
17 Correct 8 ms 3444 KB Output is correct
18 Correct 8 ms 3380 KB Output is correct
19 Correct 15 ms 3676 KB Output is correct
20 Correct 9 ms 3676 KB Output is correct