Submission #895839

# Submission time Handle Problem Language Result Execution time Memory
895839 2023-12-30T22:16:20 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
100 / 100
15 ms 4188 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

typedef long long ll;

ll r, l, x, b;
vector<ll> pref;

ll check(int R, int L, int *fields, ll B) {
  ll lo = L, hi = R;
  while (lo < hi){
    ll mid = (lo + hi + 1)/2;
    ll k = (L + mid)/2;
    ll cost = fields[k - 1]*(k - L + 1) - (pref[k] - pref[L - 1]) +(pref[mid] - pref[k]) - (mid - k)*fields[k-1];

    if (cost > B) {
      hi = mid - 1;
    } else {
      lo = mid;
    }
  }

  return lo - L + 1;
}

int besthub(int R, int L, int fields[], ll B) {
  pref.resize(R + 1);
  for(int i = 0; i < R; i++){
    pref[i+1] += pref[i];
    pref[i+1] += fields[i];
  }
  
  ll ans = INT_MIN;
  for (int i = 1; i <= R; i++) {
    ans = max(ans, check(R, i, fields, B));
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 600 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 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 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 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 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 532 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 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 500 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 600 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 13 ms 3444 KB Output is correct
4 Correct 15 ms 3420 KB Output is correct
5 Correct 7 ms 2908 KB Output is correct
6 Correct 7 ms 2908 KB Output is correct
7 Correct 12 ms 3312 KB Output is correct
8 Correct 13 ms 3420 KB Output is correct
9 Correct 8 ms 2908 KB Output is correct
10 Correct 7 ms 2928 KB Output is correct
11 Correct 14 ms 3420 KB Output is correct
12 Correct 14 ms 3420 KB Output is correct
13 Correct 9 ms 3416 KB Output is correct
14 Correct 7 ms 3420 KB Output is correct
15 Correct 10 ms 3932 KB Output is correct
16 Correct 10 ms 3932 KB Output is correct
17 Correct 14 ms 3928 KB Output is correct
18 Correct 13 ms 3932 KB Output is correct
19 Correct 15 ms 4188 KB Output is correct
20 Correct 13 ms 4044 KB Output is correct