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>
#include "candies.h"
using namespace std;
#ifdef LOCAL
void print() {cerr << "]" << endl;}
template<typename Head, typename... Tail> void print(Head H, Tail... T) {cerr << H; if(sizeof...(T)) cerr << ", "; print(T...);}
template<typename T> ostream& operator << (ostream& os, vector<T> v) {os << "["; string sep = ""; for(auto& x : v) {os << sep << x; sep = ", ";} return os << "]";}
template<typename A, typename B> ostream& operator << (ostream& os, pair<A, B> p) {return os << "(" << p.first << ", " << p.second << ")";}
#define dbg(x...) cerr << "[" << #x << ": ", print(x);
#else
#define dbg(x...) 42;
#endif // LOCAL
#define vt vector
#define sz(x) int((x).size())
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
vt<int> distribute_candies(vt<int> C, vt<int> L, vt<int> R, vt<int> v)
{
int N = sz(C);
int Q = sz(L);
vt<int> ans(N + 1);
for(int i = 0; i < Q; i++)
{
assert(v[i] > 0);
ans[L[i]] += v[i];
ans[R[i] + 1] -= v[i];
}
int cur = 0;
for(int i = 0; i < N; i++)
{
cur += ans[i];
ans[i] = min(cur, C[i]);
}
ans.resize(N);
return ans;
}
/*
int main()
{
int N;
cin >> N;
vt<int> C(N);
for(int i = 0; i < N; i++) cin >> C[i];
int Q;
cin >> Q;
vt<int> L(Q), R(Q), V(Q);
for(int i = 0; i < Q; i++) cin >> L[i] >> R[i] >> V[i];
for(int x : distribute_candies(C, L, R, V)) cout << x << " ";
cout << "\n";
}
*/
/*
3
10 15 13
1
0 2 20
*/
# | 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... |