답안 #987068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987068 2024-05-21T19:18:57 Z aaaaaarroz 쌀 창고 (IOI11_ricehub) C++17
100 / 100
14 ms 4952 KB
#include "ricehub.h"
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int besthub (int R, int L, int X[], long long B) {
  vector<int> x(R + 5);
  vector<ll> pref(R + 5);
  for (int i = 1; i <= R; i++) x[i] = X[i - 1], pref[i] = pref[i - 1] + x[i];
  auto ck = [&] (int val) {
    for (int l = 1, r = l + val - 1; r <= R; l++, r++) {
      int mid = (l + r) >> 1;
      ll curl = x[mid] * (mid - l) - (pref[mid - 1] - pref[l - 1]);
      ll curr = (pref[r] - pref[mid]) - x[mid] * (r - mid);
      if (curl + curr <= B) return 1;
    }
    return 0;
  };
  int l = 1, r = R;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (ck(mid)) l = mid + 1;
    else r = mid - 1;
  }
  return r;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 448 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 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 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 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 372 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 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 348 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 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 856 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
3 Correct 11 ms 4952 KB Output is correct
4 Correct 11 ms 4952 KB Output is correct
5 Correct 6 ms 3420 KB Output is correct
6 Correct 6 ms 3420 KB Output is correct
7 Correct 9 ms 4444 KB Output is correct
8 Correct 10 ms 4440 KB Output is correct
9 Correct 6 ms 3420 KB Output is correct
10 Correct 6 ms 3420 KB Output is correct
11 Correct 11 ms 4696 KB Output is correct
12 Correct 14 ms 4952 KB Output is correct
13 Correct 7 ms 3672 KB Output is correct
14 Correct 6 ms 3456 KB Output is correct
15 Correct 8 ms 4188 KB Output is correct
16 Correct 8 ms 4224 KB Output is correct
17 Correct 9 ms 4444 KB Output is correct
18 Correct 9 ms 4444 KB Output is correct
19 Correct 10 ms 4700 KB Output is correct
20 Correct 10 ms 4700 KB Output is correct