1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 200010 4 int big[MAXN<<2],small[MAXN<<2],lazy[MAXN<<2]; 5 int n,m,p; 6 inline int MIN(int x,int y) 7 { 8 return x>y?y:x; 9 } 10 inline int MAX(int x,int y) 11 { 12 return x>y?x:y; 13 } 14 inline void PushUp(int rt) 15 { 16 big[rt]=MAX(big[rt<<1],big[rt<<1|1]); 17 small[rt]=MIN(small[rt<<1],small[rt<<1|1]); 18 } 19 void Build(int L,int R,int rt) 20 { 21 big[rt]=small[rt]=lazy[rt]=0; 22 if(L!=R) 23 { 24 int mid=(L+R)>>1; 25 Build(L,mid,rt<<1); 26 Build(mid+1,R,rt<<1|1); 27 } 28 } 29 void PushDown(int rt) 30 { 31 if(lazy[rt]) 32 { 33 big[rt<<1]+=lazy[rt]; 34 big[rt<<1|1]+=lazy[rt]; 35 small[rt<<1]+=lazy[rt]; 36 small[rt<<1|1]+=lazy[rt]; 37 lazy[rt<<1]+=lazy[rt]; 38 lazy[rt<<1|1]+=lazy[rt]; 39 lazy[rt]=0; 40 } 41 } 42 void Update(int x,int y,int val,int L,int R,int rt) 43 { 44 if(x<=L&&R<=y) 45 { 46 if(big[rt]<p) 47 { 48 small[rt]+=val; 49 big[rt]+=val; 50 lazy[rt]+=val; 51 return; 52 } 53 if(small[rt]>=p) 54 { 55 small[rt]+=val<<1; 56 big[rt]+=val<<1; 57 lazy[rt]+=val<<1; 58 return; 59 } 60 } 61 int mid=(L+R)>>1; 62 PushDown(rt); 63 if(mid>=x) 64 Update(x,y,val,L,mid,rt<<1); 65 if(y>mid) 66 Update(x,y,val,mid+1,R,rt<<1|1); 67 PushUp(rt); 68 } 69 void OUT(int L,int R,int rt) 70 { 71 if(L==R) 72 { 73 if(L==1) 74 printf("%d",big[rt]); 75 else 76 printf(" %d",big[rt]); 77 } 78 else 79 { 80 int mid=(L+R)>>1; 81 PushDown(rt); 82 OUT(L,mid,rt<<1); 83 OUT(mid+1,R,rt<<1|1); 84 } 85 } 86 int main() 87 { 88 int a,b,c; 89 while(~scanf("%d%d%d",&n,&m,&p)) 90 { 91 Build(1,n,1); 92 while(m--) 93 { 94 scanf("%d%d%d",&a,&b,&c); 95 Update(a,b,c,1,n,1); 96 } 97 OUT(1,n,1); 98 putchar('\n'); 99 } 100 return 0; 101 }