답안 #476113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476113 2021-09-24T19:36:22 Z Haidara 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
/** * * * * * * * * * * * * * **\
 *                             *
 *   Author: Haidara Nassour   *
 * Coded in: YYYY\M\D HH:MM:SS *
 *          Lang: C++          *
 *                             *
\** * * * * * * * * * * * * * **/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define int long long
#define itn int
#define rep(i,x,n) for(int i=(x);i<(n);i++)
#define FOR(i,n) rep(i,0,n)
#define per(i,x,n) for(int i=(x);i>(n);i--)
#define ROF(i,x) for(int i=x;i>=0;i--)
#define v(i) vector< i >
#define p(i,j) pair< i , j >
#define pii pair<int,int>
#define m(i,j) map< i , j >
#define um(i,j) unordered_map< i , j >
#define max_heap(i) priority_queue< i >
#define min_heap(i) priority_queue< i , vector< i > ,greater< i > >
#define ff first
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ss second
#define pp push_back
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
#define debug(x) cout<<#x<<" ";
using namespace std;
const int inf=1e9+7;
const int mod=1e9+7;
const int maxn=200200;
int n;
struct node
{
    int val,lazy;
    node():val(0),lazy(0){}
}st[maxn*4];
void pull(int inx,int l,int r)
{
    st[inx].val+=st[inx].lazy;
    if(l!=r)
    {
        st[inx*2].lazy+=st[inx].lazy;
        st[inx*2+1].lazy+=st[inx].lazy;
    }
    st[inx].lazy=0;
}
void update(int ul,int ur,int val,int l=1,int r=n,int inx=1)
{
    pull(inx,l,r);
    if(ul<=l&&r<=ur)
    {
        st[inx].lazy+=val;
        pull(inx,l,r);
        return ;
    }
    if(l>ur||ul>r)
        return ;
    int mid=l+(r-l)/2;
    update(ul,ur,val,l,mid,inx*2);
    update(ul,ur,val,mid+1,r,inx*2+1);
}
int query(int pos,int l=1,int r=n,int inx=1)
{
    pull(inx,l,r);
    if(l==r)
        return st[inx].val;
    int mid=l+(r-l)/2;
    if(pos<=mid)
        return query(pos,l,mid,inx*2);
    return query(pos,mid+1,r,inx*2+1);
}
vector<int> distribute_candies(vector<int> C, vector<int> L, vector<int> R, vector<int> V)
{
    build(C);
    n=C.size();
    FOR(i,(int)L.size())
        update(L[i]+1,R[i]+1,V[i]);
    v(int)ans(n);
    FOR(i,n)
        ans[i]=min(query(i+1),C[i]);
    return ans;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:78:5: error: 'build' was not declared in this scope
   78 |     build(C);
      |     ^~~~~