Carrot Trees
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Walk Alone planted n magical carrot trees in a row. Let a_i denote the number of carrots on the i-th tree (note that a_i is a real number). Initially, there are no carrots on any tree. On each day, he can do one of the following two operations on the trees:
  • \texttt{1 l r x}. Water all carrot trees between \ell and r inclusively. After that, a_i will increase by x/k immediately for all \ell \leq i \leq r, where k is a constant in all operations.
  • \texttt{2 l r}. Pick a carrot from all trees between \ell and r inclusively and having at least one carrot. After that, a_i will decrease by 1 for all integers i where \ell \leq i \leq r and a_i \ge 1.
After m days, Walk Alone has picked many carrots, and he wants you to tell him the total number of carrots he harvested.

输入描述:

The first line contains three integers n\ (1\leq n\leq 10^6), m\ (1 \leq m \leq 2\cdot 10^5) and k\ (1\leq k\leq 10^9), indicating the number of carrots, the number of operations, and the constant in the first operation.
Each of the following m lines indicates an operation, the format of which is as above. It is guaranteed that 1\leq \ell\leq r\leq n and 1 \leq x \leq 10^9.

输出描述:

Output an integer indicating the total number of carrots.
示例1

输入

复制
5 5 3
1 1 3 4
2 2 4
1 1 2 3
1 4 5 3
2 1 4

输出

复制
5