답안 #834655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
834655 2023-08-22T16:34:07 Z Mohmad_Zaid 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include "candies.h"
#include <vector>
#define ll long long
using namespace std;
struct segtree{
    int size=1;
    vector<ll>arr;
    void init(int n){
        while(size<n)size*=2;
        arr.assign(2*size,0LL);
    }
    void update(int l,int r,int x,int lx,int rx,int v){
        if(lx>=r || rx<=l)return;
        if(lx>=l && rx<=r){
            arr[x]+=v;
            return;
        }
        int mid=(lx+rx)/2;
        update(l,r,2*x+1,lx,mid,v);
        update(l,r,2*x+2,mid,rx,v);
    }
    void update(int l,int r,int v){
        update(l,r,0,0,size,v);
    }
    void get_ans(int i,int x,int lx,int rx,ll& ans){
        if(lx>i || rx<=i)return;
        if(rx-lx==1){
            if(lx==i)ans+=arr[x];
            return;
        }
        if(lx<=i && rx>i){
            ans+=arr[x];
        }
        int mid=(lx+rx)/2;
        if(i<mid)get_ans(i,2*x+1,lx,mid,ans);
        else get_ans(i,2*x+2,mid,rx,ans);
    }
    void get_ans(int i,ll& ans){
        get_ans(i,0,0,size,ans);
    }
};
vector<int> distribute_candies(vector<int> c, vector<int> l,vector<int> r, vector<int> v) {
    int n = c.size();
    int q=l.size();
    vector<ll> s(n);
    segtree st;
    st.init(n);
    for(int i=0;i<q;i++){
        st.update(l[i],r[i]+1,v[i]);
    }
    for(int i=0;i<n;i++){
        ll val=0;
        st.get_ans(i,val);
        s[i]=min((ll)c[i],val);
    }
    return s;
}

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:56:12: error: could not convert 's' from 'vector<long long int>' to 'vector<int>'
   56 |     return s;
      |            ^
      |            |
      |            vector<long long int>