Submission #679026

# Submission time Handle Problem Language Result Execution time Memory
679026 2023-01-07T08:10:39 Z atigun Rice Hub (IOI11_ricehub) C++11
Compilation error
0 ms 0 KB
#include "ricehub.h"

int R;
ll L, B;
vector<ll> X, pf;

ll get(int l, int r){
  return pf[r]-pf[l-1];
}
ll sz(int l, int r){
  return r-l+1;
}
ll go(int l, int r){
  int mid = (l+r)/2;
  ll lsum = sz(l, mid)*X[mid]-get(l, mid);
  ll rsum = get(mid+1, r)-sz(mid+1, r)*X[mid];
  return lsum+rsum;
}

int besthub(int rr, int ll, int xx[], long long bb){
  R = rr, L = ll, B = bb;
  X.resize(R+5);
  for(int i = 1; i <= R; i++)
    X[i] = xx[i-1];
  pf = X;
  for(int i = 1; i <= R; i++)
    pf[i]+= pf[i-1];
  int left = 0, right = 0;
  int ans = 0;
  while(left <= R){
    while(right+1 <= R && go(left, right+1) <= B)
      right++;
    ans = max(ans, right-left+1);
    left++;
  }
  return ans;
}

Compilation message

ricehub.cpp:4:1: error: 'll' does not name a type
    4 | ll L, B;
      | ^~
ricehub.cpp:5:1: error: 'vector' does not name a type
    5 | vector<ll> X, pf;
      | ^~~~~~
ricehub.cpp:7:1: error: 'll' does not name a type
    7 | ll get(int l, int r){
      | ^~
ricehub.cpp:10:1: error: 'll' does not name a type
   10 | ll sz(int l, int r){
      | ^~
ricehub.cpp:13:1: error: 'll' does not name a type
   13 | ll go(int l, int r){
      | ^~
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:21:11: error: 'L' was not declared in this scope
   21 |   R = rr, L = ll, B = bb;
      |           ^
ricehub.cpp:21:19: error: 'B' was not declared in this scope
   21 |   R = rr, L = ll, B = bb;
      |                   ^
ricehub.cpp:22:3: error: 'X' was not declared in this scope
   22 |   X.resize(R+5);
      |   ^
ricehub.cpp:25:3: error: 'pf' was not declared in this scope
   25 |   pf = X;
      |   ^~
ricehub.cpp:31:27: error: 'go' was not declared in this scope
   31 |     while(right+1 <= R && go(left, right+1) <= B)
      |                           ^~
ricehub.cpp:33:11: error: 'max' was not declared in this scope
   33 |     ans = max(ans, right-left+1);
      |           ^~~