답안 #880435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880435 2023-11-29T12:29:01 Z andro 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#include "ricehub.h"

#define int long long

using namespace std;

const int N=5005;

struct seg{
    int t[4*N];
    int lazy[4*N];
    void propagate(int v,int tl,int tr){
        t[v]+=(tr-tl+1)*lazy[v];
        if(tl!=tr){
            t[v*2]+=lazy[v];
            t[v*2+1]+=lazy[v];
        }
        lazy[v]=0;
    }
    int query(int v,int tl,int tr,int l,int r){
        propagate(v,tl,tr);
        if(tl>=l&&tr<=r)return t[v];
        if(tl>r||tr<l)return 0;
        int tm=(tl+tr)/2;
        return query(v*2,tl,tm,l,r)+query(v*2+1,tm+1,tr,l,r);
    }
    void update(int v,int tl,int tr,int l,int r,int x){
        propagate(v,tl,tr);
        if(tl>=l&&tr<=r){
            lazy[v]+=x;
            propagate(v,tl,tr);
            return;
        }
        if(tl>r||tr<l)return;
        int tm=(tl+tr)/2;
        update(v*2,tl,tm,l,r,x);
        update(v*2+1,tm+1,tr,l,r,x);
        t[v]=t[v*2]+t[v*2+1];
    }
};

int besthub(int R, int L, int X[], long long B){
    int ans=0;
    for(int i=1;i<=R;i++){
        //od desno kolko ih ima u [X[i],X[i]+mid]
        // od levo [X[i]-mid,X[i]]
        int l=0,r=1e15+1,p=-1;
        while(l<=r){
            int mid=(l+r)/2;
            int c=0;
            for(int j=1;j<=R;j++){
                if(abs(X[i]-X[j])<=mid)c+=abs(X[i]-X[j]);
            }
            if(c<=B){
                l=mid+1;
                p=mid;
            }
            else {
                r=mid-1;
            }
        }
        int u=0;
        for(int j=1;j<=R;j++){
            if(abs(X[i]-X[j])<=p)u++;
        }
        ans=max(ans,u);
    }
    return ans;
}/*
signed main(){
    int X[4]={0,10,12,14};
    cout<<besthub(3,14,X,6);
}*/
/*
1 3
2 3
3 3
3
*/

Compilation message

/usr/bin/ld: /tmp/cck7tD9e.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status