Submission #806809

# Submission time Handle Problem Language Result Execution time Memory
806809 2023-08-04T10:02:18 Z Gangsta Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
// a >> b = a / pow(2,b)
// a << b = a * pow(2,b)
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define sz size()
#define ss second
#define ff first
#define N 200001
#define pll pair<ll,ll>

using namespace std;

bool check(int md, ll b, vector<int>arr){
	int n = arr.sz, p = (md-1) / 2;
	ll cost = 0;
	for(int i = 0; i < md; i++) cost += abs(arr[p] - arr[i]);
	if(cost <= b) return true;
	for(int i = md; i < n; i++){
		int x = arr[i - md], y = arr[i];
		int m = arr[p], mp = arr[p+1];
		p++;
		if(k&1){
			cost += x + y;
			cost -= m + mp;
		}
		else{
			cost += x + y;
			cost -= mp + mp;
		}
		if(cost <= B) return true;
	}
	return false;
}

int besthub(int r, int l, int x[N], ll b){
	vector <int> arr;
	for(int i = 0; i < r; i++) arr.pb(x[i]);
	int st = 1, en = r, md = 0, answer = -1;
	while(st <= en){
		md = (st + en) >> 1;
		if(check(md, b, arr)){
			answer = md;
			st = md + 1;
		}
		else en = md - 1;
	}
	return answer;
}

//int main(){
//	ll r, l, x[N], b;
//	cin >> r >> l;
//	for(int i = 0; i < r; i++) cin >> x[i];
//	cin >> b;
//	cout << besthub(r,l,x,b);
//}

Compilation message

ricehub.cpp: In function 'bool check(int, long long int, std::vector<int>)':
ricehub.cpp:23:6: error: 'k' was not declared in this scope
   23 |   if(k&1){
      |      ^
ricehub.cpp:31:14: error: 'B' was not declared in this scope
   31 |   if(cost <= B) return true;
      |              ^