#B4057. Farmer Z's Flower Pots
Farmer Z's Flower Pots
Farmer Z's Flower Pots
Farmer Z has a row of n flower pots numbered from 1 to n from left to right. Each pot contains a flower with height \(h_i\). Initially, all \(h_i=0\).
For the next m days, Farmer Z will perform one of the following operations each day:
water l r
: Water the pots numbered from l to r, increasing each \(h_i\) (for \(l \le i \le r\)) by 1.rise l r k
: For pots numbered from l to r, in order, check each pot \(i\). If \(h_i \ge k\), then pick the flower from pot \(i\) (i.e. set \(h_i\) to 0).
For each rise
operation, output an integer \(c\) on a new line representing the number of flowers that were picked.
inputFormat
The first line contains two integers \(n\) and \(m\) representing the number of flower pots and the number of days respectively.
The following m lines each contain an operation in one of the two formats:
water l r
rise l r k
It is guaranteed that the operations are valid.
outputFormat
For each rise
operation, output a single line containing the integer \(c\), the number of flowers picked on that day.
sample
5 5
water 1 5
water 2 4
rise 1 3 2
water 3 5
rise 1 5 1
2
4
</p>