Submission #895836

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

typedef long long ll;

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

int check(int R, int L, int *fields, ll B) {
  int lo = L, hi = R;
  while (lo < hi){
    int mid = (lo + hi + 1)/2;
    int 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];
  }
  
  int 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 344 KB Output is correct
2 Correct 0 ms 348 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
# 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 1 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 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 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 1 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 444 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 580 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 0 ms 348 KB Output is correct
25 Correct 0 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 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 348 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 448 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 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 0 ms 344 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 456 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 460 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 14 ms 4196 KB Output is correct
4 Correct 14 ms 4188 KB Output is correct
5 Correct 7 ms 3164 KB Output is correct
6 Correct 7 ms 3416 KB Output is correct
7 Correct 15 ms 4184 KB Output is correct
8 Correct 13 ms 4188 KB Output is correct
9 Correct 7 ms 3272 KB Output is correct
10 Correct 7 ms 3160 KB Output is correct
11 Correct 15 ms 4188 KB Output is correct
12 Correct 14 ms 4188 KB Output is correct
13 Incorrect 7 ms 3464 KB Output isn't correct
14 Halted 0 ms 0 KB -