# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830885 | 2023-08-19T12:31:51 Z | Johann | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include "candies.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vi; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() int N, Q; std::vector<int> distribute_candies(vi c, vi l, vi r, vi v) { N = sz(c); Q = sz(l); vi S(N, 0); for (int q = 0; q < Q; ++q) { S[l[q]] += v[q]; S[++r[q]] -= v[q]; } partial_sum(all(S), S.begin()); for (int i = 0; i < N; ++i) S[i] = min(c[i], S[i]); vector<int> ans; for (ll x : S) ans.push_back(x); return ans; }