#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)
using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
//const int mod = 1000000007;
//Note to self: Check for overflow
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v)
{
int n=(int)c.size();
int q=(int)v.size();
if (n<=3000 && q<=3000)
{
vector<int> stored(n,0);
ff(qq,0,q)
{
fff(i,l[qq],r[qq]) stored[i]+=v[qq];
fff(i,l[qq],r[qq]) stored[i]=max(stored[i],0);
fff(i,l[qq],r[qq]) stored[i]=min(stored[i],c[i]);
}
return stored;
}
else
{
return c;
}
}
int main()
{
vector<int> c,l,r,v;
int n; cin>>n;
ff(i,0,n)
{
int x; cin>>x;
c.pb(x);
}
int q; cin>>q;
while (q--)
{
int ll,rr,vv; cin>>ll>>rr>>vv;
l.pb(ll),r.pb(rr),v.pb(vv);
}
vector<int> ans=distribute_candies(c,l,r,v);
for (auto it : ans) cout<<it<<" "; cout<<endl;
}
//Note to self: Check for overflow
Compilation message
candies.cpp: In function 'int main()':
candies.cpp:77:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
77 | for (auto it : ans) cout<<it<<" "; cout<<endl;
| ^~~
candies.cpp:77:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
77 | for (auto it : ans) cout<<it<<" "; cout<<endl;
| ^~~~
/usr/bin/ld: /tmp/ccX4iaFu.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLb6K9w.o:candies.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status