답안 #61020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61020 2018-07-25T06:05:50 Z nvmdava 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

vector<long long> v
bool price(X[], int l,int r, long long B){
	
	int i;
	long long p = 0;
	int m = (r + l) / 2;
	
	p = x[m] * (m - l) - v[m] + v[l] + v[r + 1] - v[m + 1] - x[m] * (r - m);
	
	if(p <= B){
		return 1;
	} else {
		return 0;
	}
	
}

int besthub(int n, int L, int X[], long long B)
{
	v.push_back(0);
	for(i = 0; i < n; i ++){
		v.push_back(v.back() + X[i]);
	}
	int l = 0, r = 0, m,dif = -1,i;
	for(i = 0; i < n;i++){
		l = i; r = n ;
		while(l + 1 != r){
			m = (l+r) / 2;
			if(price(X,i,m,B)){
				l = m;
			} else {
				r = m;
			}
		}
		dif = max(dif , r - i);
	}
	return dif;
}

Compilation message

ricehub.cpp:6:1: error: expected initializer before 'bool'
 bool price(X[], int l,int r, long long B){
 ^~~~
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:24:2: error: 'v' was not declared in this scope
  v.push_back(0);
  ^
ricehub.cpp:25:6: error: 'i' was not declared in this scope
  for(i = 0; i < n; i ++){
      ^
ricehub.cpp:33:7: error: 'price' was not declared in this scope
    if(price(X,i,m,B)){
       ^~~~~