Submission #836898

# Submission time Handle Problem Language Result Execution time Memory
836898 2023-08-24T16:59:50 Z ma_moutahid Distributing Candies (IOI21_candies) C++17
0 / 100
89 ms 11460 KB
#include "candies.h"
#include  <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vii vector<vi>
using ll=long long;
#define vl vector<long long>

ll np(int n){
    while(n & (n-1))n++;
    return n;
}

vl segtree;

void update(ll pos, ll l, ll r, ll x, ll y, ll value){
    if(y<l)return;
    if(x>r)return;
    if(l>=x && r<=y){
        segtree[pos]+=value;

        return;
    }
    update(pos*2,l,(l+r)/2,x,y,value);
    update(pos*2+1,(l+r)+1,r,x,y,value);
}


std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
    int n = c.size();
    int q=l.size();
    int N=np(n);
    segtree.resize(2*N);
    std::vector<int> s(n);
    for(int i=0;i<q;i++){
        int x=l[i];
        int y=r[i];
        update(1,0,N-1,x,y,v[i]);
    }
    for(int i=1;i<N;i++){
        segtree[2*i]+=segtree[i];
        segtree[2*i+1]+=segtree[i];
    }
    for(int i=0;i<n;i++){
        s[i]=segtree[N+i];
    }
    return s;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 11460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -