Submission #969905

# Submission time Handle Problem Language Result Execution time Memory
969905 2024-04-25T19:17:51 Z urieg Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB

#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
// for moondance

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

    vector<ll>x(R), p(R);
    for(int i=0;i<R;i++){
        x[i] = z[i];
        p[i] = x[i];
        if(i)p[i] += p[i-1];
    }


    int ans = 0;
    ll sum = 0;
    int l = 0, r = 0;
    for(int i =0;i<R;i++){
        l = r = i;
        sum = 0;
        while(l>0 && r<R-1 && sum <= B){
            if(l>0 && r<R-1){
                if(x[i]-x[l-1] < x[r+1]-x[i]){
                    if(sum + x[i]-x[l-1] <= B){
                        sum += x[i]-x[l-1];
                        l--;
                    }
                    else break;
                }
                else{
                    if(sum + x[r+1]-x[i] <= B){
                        sum += x[r+1]-x[i];
                        r++;
                    }
                    else break;
                }
            }
            else if(l>0){
                if(sum + x[i]-x[l-1] <= B){
                    sum += x[i]-x[l-1];
                    l--;
                }
                else break;
            }
            else if(r<R-1){
                if(sum + x[r+1]-x[i] <= B){
                    sum += x[r+1]-x[i];
                    r++;
                }
                else break;
            }
        }
        ans = max(ans, r-l+1);
    }
    return ans;
}




Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:13:16: error: 'z' was not declared in this scope
   13 |         x[i] = z[i];
      |                ^