답안 #634650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
634650 2022-08-24T16:24:29 Z rockoana 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <vector>

#include "ricehub.h"

using namespace std;

vector<long long> s;
long long cost(int st, int dr, int X[]) {
  int mid = (st + dr) / 2;
  // X[mid + 1] - X[mid] + X[mid + 2] - X[mid]...X[dr] - X[mid];
  // X[mid] - X[mid] + X[mid] - X[mid - 1] + ... + X[mid] - X[st]

  long long res = s[dr] - s[mid] - s[mid];
  if (st != 0) {
    res += s[st - 1];
  }

  if ((dr - st + 1) % 2 == 1) {
    res += X[mid];
  }

  return res;
}

int besthub(int R, int L, int X[], long long B) {
  s.assign(R, 0);
  for (i64 i = 0; i < R; i++) {
    s[i] += X[i];
    if (i != 0) {
      s[i] += s[i - 1];
    }
  }

  int st = 0;
  int res = 0;
  for (int i = 0; i < R; i++) {
    while (cost(st, i, X) > B) {
      st++;
    }

    res = max(res, i - st + 1);
  }

  return res;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:27:8: error: 'i64' was not declared in this scope
   27 |   for (i64 i = 0; i < R; i++) {
      |        ^~~
ricehub.cpp:27:19: error: 'i' was not declared in this scope
   27 |   for (i64 i = 0; i < R; i++) {
      |                   ^