# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
602769 | Siffer | Distributing Candies (IOI21_candies) | C++17 | 128 ms | 15444 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> s;
ll gett(int i) {
i += s.size()>>1;
ll r = 0;
for(;i;i>>=1) r += s[i];
return r;
}
void up(int a, int b, ll v) {
a += s.size()>>1; b += s.size()>>1;
for(;a <= b; a >>= 1, b >>= 1) {
if(a&1) s[a] += v, a++;
if((b&1)==0) s[b] += v, b--;
}
}
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
int p = 1; for(;p <= n; p <<= 1); p <<= 1;
s.resize(p,0);
for(int i = 0; i < l.size(); i++) up(l[i],r[i],v[i]);
vector<int> k(n,0);
for(int i = 0; i < n; i++) k[i] = min(gett(i), c[i]+0ll);
return k;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |