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 <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
int n, q;
vector<ll> distribute_candies(vi c, vi l, vi r, vi v) {
n = (int)c.size();
q = (int)l.size();
vector<ll> ans(n);
for(int i = 0; i < q; ++i) {
ans[l[i]] += v[i];
if(r[i] + 1 < n) ans[r[i] + 1] -= v[i];
}
for(int i = 1; i < n; ++i) {
ans[i] += ans[i - 1];
}
for(int i = 0; i < n; ++i) {
ans[i] = min(ans[i], (ll)c[i]);
}
return ans;
}
//int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//vector<ll> w = distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {20, -11});
//for(int x : w) {
//cout << x << " ";
//}
//}
# | 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... |