Distributing Candies

아직 제출이 없습니다시간 제한4초메모리 제한2048 MB

문제

Aunty Khong is preparing nn boxes of candies for students from a nearby school. The boxes are numbered from 00 to n1n - 1 and are initially empty. Box ii (0in10 \le i \le n - 1) has a capacity of c\[i]c\[i] candies.

Aunty Khong spends qq days preparing the boxes. On day jj (0jq10 \le j \le q - 1), she performs an action specified by three integers l\[j]l\[j], r\[j]r\[j] and v\[j]v\[j] where 0l\[j]r\[j]n10 \le l\[j] \le r\[j] \le n - 1 and v\[j]0v\[j] \ne 0. For each box kk satisfying l\[j]kr\[j]l\[j] \le k \le r\[j]:

  • If v\[j]>0v\[j] > 0, Aunty Khong adds candies to box kk, one by one, until she has added exactly v\[j]v\[j] candies or the box becomes full. In other words, if the box had pp candies before the action, it will have min(c\[k],p+v\[j])\min{(c\[k], p + v\[j])} candies after the action.
  • If v\[j]<0v\[j] < 0, Aunty Khong removes candies from box kk, one by one, until she has removed exactly v\[j]-v\[j] candies or the box becomes empty. In other words, if the box had pp candies before the action, it will have max(0,p+v\[j])\max{(0, p + v\[j])} candies after the action.

Your task is to determine the number of candies in each box after the qq days.

제한

  • 1n200,0001 \le n \le 200\\,000
  • 1q200,0001 \le q \le 200\\,000
  • 1c\[i]1091 \le c\[i] \le 10^9 (for all 0in10 \le i \le n - 1)
  • 0l\[j]r\[j]n10 \le l\[j] \le r\[j] \le n - 1 (for all 0jq10 \le j \le q - 1)
  • 109 v\[j]109-10^9 \le v\[j] \le 10^9, v\[j]0v\[j] \ne 0 (for all 0jq10 \le j \le q - 1)