#include<cstring> #include<cstdio> #include<algorithm> #define tree int o,int l,int r #define lson o<<1,l,mid #define rson o<<1|1,mid+1,r #define lo o<<1 #define ro o<<1|1 #define inf 2e9 #define eps 1e-7 #define N 200009 using namespace std; int m,n,T,t,q,p; int ql,qr,c; int minx[N<<2],lazy[N<<2],val[N<<2]; void build(tree) { minx[o]=p; lazy[o]=0; if(l<r) { int mid=(l+r)>>1; build(lson); build(rson); } } void init() { memset(val,0,sizeof(val[0])*(n+1)); memset(lazy,0,sizeof(lazy)); build(1,1,n); return ; } void pushup(int o) { minx[o]=min(minx[lo],minx[ro]); } void pushdown(int o) { if(lazy[o]) { lazy[lo]+=lazy[o]; lazy[ro]+=lazy[o]; minx[lo]-=lazy[o];//修改子节点的所有信息,WA minx[ro]-=lazy[o]; lazy[o]=0; } } void update(tree) { if(l==r) { if(val[l]>=p) val[l]+=(c+lazy[o])*2; else val[l]+=c+lazy[o]; lazy[o]=0; minx[o]=p-val[l];//WA if(minx[o]<=0) minx[o]=inf; } else { int mid=(l+r)>>1; if(ql<=l&&qr>=r) { if(minx[o]<=c) { pushdown(o); if(ql<=mid)update(lson); if(qr>mid)update(rson); pushup(o); } else { minx[o]-=c; lazy[o]+=c; } } else { pushdown(o); if(ql<=mid)update(lson); if(qr>mid)update(rson); pushup(o); } } } void query(tree) { if(l==r) { if(val[l]>=p) val[l]+=(lazy[o])*2; else val[l]+=lazy[o]; printf("%d%c",val[l],l==n?' ':' '); } else { pushdown(o); int mid=(l+r)>>1; query(lson); query(rson); // pushup(o); } } int main() { #ifndef ONLINE_JUDGE freopen("ex.in","r",stdin); #endif while(scanf("%d%d%d",&n,&q,&p)==3) { init(); while(q--) { scanf("%d%d%d",&ql,&qr,&c); update(1,1,n); } query(1,1,n); } return 0; }