# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1137369 | valid | Distributing Candies (IOI21_candies) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;++i){
cin>>a[i];
}
int q,c;
cin>>q;
while(q--){
int l,r,v;
cin>>l>>r>>v;
for(int i=l;i<=r;++i){
int p=a[i];
if(v>0){
a[i]=min(a[i],p+v);
}else if(v<0){
a[i]=max(0,p+v);
}
}
}
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
return 0;
}