Submission #1217113

#TimeUsernameProblemLanguageResultExecution timeMemory
1217113nataliaaRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
    long long ans = 0;
	int l = 0, r = R;
	long long pre[R+1]={};
	for(int i = 0; i< n; i++) pre[i+1]=pre[i]+x[i];
	while(l<=r) {
	    int m = (l+r)/2;
	    bool t = 0;
	    for(int i = 0; i < R ; i++) {
	        if(i+m<=R) {
	            int cnt = 0;
	            int k = (m+i-1)/2;
	            cnt+=(k - i)*X[k] - (pre[k] - pre[i]) + (pre[i+m] - pre[k +1]) - (i+m - k)*pre[k];
	            if(cnt<=B) {
	                t=1;
	                break;
	            }
	        }
	        else break;
	    }
	    if(t) l = m+1;
	    else r= m-1;
	    
	}
	return r;
}

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:9:27: error: 'n' was not declared in this scope
    9 |         for(int i = 0; i< n; i++) pre[i+1]=pre[i]+x[i];
      |                           ^
ricehub.cpp:9:51: error: 'x' was not declared in this scope
    9 |         for(int i = 0; i< n; i++) pre[i+1]=pre[i]+x[i];
      |                                                   ^