답안 #61299

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61299 2018-07-25T15:36:31 Z TuGSGeReL 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
    #include "ricehub.h"
    #include<bits/stdc++.h>
    #define ll long long
    #define mp make_pair
    #define pub push_back
    #define pob pop_back
    using namespace std;
    ll i,ans,a[111111],c[111111];
    bool can(ll k, ll kk, int x[],ll B){
    	ll md=(k+kk)/2,cst;
    	cst=(md-k-kk+md)*x[md]-c[md]+c[k]+c[kk+1]-c[md+1];
    	if(cst<=B) return 1;
    	else return 0;
    }
    int besthub(int n, int L, int X[], long long B) {
    	c[0]=a[0];
    	for(i=1;i<n;i++)c[i]=c[i-1]+a[i];
    	for(i=0;i<n;i++){
    		ll x=i,y=n;
    		while(x+1!=y){
    			ll mid=(x+y)/2;
    			if(can(i,mid,x,B))x=mid;
    			else y=mid;
    		}
			ans=max(ans,y-i);
		}
    	return ans;
    }

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:22:24: error: invalid conversion from 'long long int' to 'int*' [-fpermissive]
        if(can(i,mid,x,B))x=mid;
                        ^
ricehub.cpp:9:10: note:   initializing argument 3 of 'bool can(long long int, long long int, int*, long long int)'
     bool can(ll k, ll kk, int x[],ll B){
          ^~~