답안 #526105

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526105 2022-02-13T18:19:18 Z Deepesson 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
typedef std::pair<long long,long long> pli;
pli custo(long long P,long long R,int X[],long long B){
    std::vector<long long> vec;
    for(int i=0;i!=R;++i){
        long long dist = abs(X[i]-P);
        vec.push_back(dist);
    }
    std::sort(vec.begin(),vec.end());
    int res=0;
    for(auto&x:vec){
        if(x<=B){
            ++res;
            B-=x;
            continue;
        }
    }
    return {res,B};
}
int besthub(int R, int L, int X[], long long B)
{
   long long la=0,ra=L-1;
   while(ra-la>1){
        int m = (la+ra+1)/2;
        pli alpha = custo(m,R,X,B);
        pli beta = custo(m+1,R,X,B);
        if(alpha>beta){
            ra=m;
        }else lo=m;
   }
   return custo(la+1,R,X,B).first;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:30:15: error: 'lo' was not declared in this scope; did you mean 'la'?
   30 |         }else lo=m;
      |               ^~
      |               la