답안 #743191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743191 2023-05-17T08:43:19 Z Joo 쌀 창고 (IOI11_ricehub) C++17
100 / 100
13 ms 2404 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

const int MXN = 1e5 + 10;
using ll = long long;

ll qs[MXN];

inline ll getSum(int l, int r)
{
  if (l > r)
    return 0;
  if (l <= 0)
    return qs[r];
  return qs[r] - qs[l - 1];
}

bool chk(int ws, int R, ll B)
{
  for (int i = (ws + 1) / 2; i + ws / 2 <= R; i++)
  {
    ll rightSum = getSum(i + 1, i + ws / 2);
    ll leftSum = getSum(i - ws / 2 + (ws % 2 == 0), i - 1 + (ws % 2 == 0));
    if (rightSum - leftSum <= B)
      return true;
  }
  return false;
}

int besthub(int R, int L, int X[], long long B)
{
  for (int i = 0; i < R; i++)
    qs[i + 1] = qs[i] + X[i];
  int l = 1, r = R, ans = -1;
  while (l <= r)
  {
    int mid = (l + r) >> 1;
    if (chk(mid, R, B))
    {
      ans = mid;
      l = mid + 1;
    }
    else
    {
      r = mid - 1;
    }
  }
  assert(ans != -1);
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 300 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 11 ms 1364 KB Output is correct
4 Correct 10 ms 1368 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 10 ms 1444 KB Output is correct
8 Correct 13 ms 1428 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 5 ms 852 KB Output is correct
11 Correct 11 ms 1364 KB Output is correct
12 Correct 11 ms 1364 KB Output is correct
13 Correct 9 ms 852 KB Output is correct
14 Correct 7 ms 1200 KB Output is correct
15 Correct 9 ms 1924 KB Output is correct
16 Correct 8 ms 1968 KB Output is correct
17 Correct 10 ms 2272 KB Output is correct
18 Correct 11 ms 2212 KB Output is correct
19 Correct 11 ms 2404 KB Output is correct
20 Correct 11 ms 2364 KB Output is correct