답안 #895766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895766 2023-12-30T18:58:30 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
100 / 100
12 ms 4444 KB
#include "bits/stdc++.h"
#include "ricehub.h"

using namespace std;
#define ll long long

int besthub(int R, int L, int X[], long long B)
{


  vector<ll> a(R + 1);

  for (int i = 1; i <= R; i++) {
    a[i] = X[i - 1];
    a[i] += a[i - 1];
  }

  int ans = 0;

  int ptr = 1;
  for (int i = 1; i <= R; i++) {
    ptr = max(ptr, i);

    while (ptr + 1 <= R) {

      ll nmid = i + ((ptr + 1) - i + 1) / 2;

      ll tot = (a[ptr + 1] - a[nmid]) - ((ll)(ptr + 1) - nmid) * X[nmid - 1];

      tot += (((ll)(nmid - i + 1))) * X[nmid - 1] - (a[nmid] - a[i - 1]);

      // cout << i << " -> " << ptr + 1 << " takes " << tot << endl;

      if (tot > B) break;
      ptr++;

    }

    ans = max(ans, ptr - i + 1);

    // cout << i << " : " << ptr << endl;

  }

  return ans;

}

// int main() {

//   int xx[5] = {1, 2, 10, 12, 14};
//   cout << besthub(5, 20, xx, 6) << endl;

// }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 348 KB Output is correct
6 Correct 0 ms 344 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 344 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 344 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 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 352 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 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 0 ms 348 KB Output is correct
8 Correct 1 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 1 ms 344 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 0 ms 348 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 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 480 KB Output is correct
22 Correct 1 ms 600 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 344 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 2 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 11 ms 4444 KB Output is correct
4 Correct 11 ms 4444 KB Output is correct
5 Correct 5 ms 3248 KB Output is correct
6 Correct 5 ms 3388 KB Output is correct
7 Correct 12 ms 4184 KB Output is correct
8 Correct 9 ms 4188 KB Output is correct
9 Correct 5 ms 3164 KB Output is correct
10 Correct 5 ms 3164 KB Output is correct
11 Correct 11 ms 4444 KB Output is correct
12 Correct 10 ms 4288 KB Output is correct
13 Correct 6 ms 3380 KB Output is correct
14 Correct 6 ms 3420 KB Output is correct
15 Correct 8 ms 4200 KB Output is correct
16 Correct 8 ms 3932 KB Output is correct
17 Correct 9 ms 4300 KB Output is correct
18 Correct 10 ms 4188 KB Output is correct
19 Correct 10 ms 4188 KB Output is correct
20 Correct 10 ms 4196 KB Output is correct