8940: Carrot Trees

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:2 通过:0

题目描述

链接:https://ac.nowcoder.com/acm/contest/57355/C
来源:牛客网
Walk Alone planted n magical carrot trees in a row. Let ai denote the number of carrots on the i-th tree (note that ai 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:
  • 1 l r x. Water all carrot trees between l and r inclusively. After that, ai will increase by x/k immediately for all l≤i≤r, where k is a constant in all operations.
  • 2 l r. Pick a carrot from all trees between l and r inclusively and having at least one carrot. After that, ai will decrease by 1 for all integers i where l≤i≤r and ai≥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≤n≤10^6), m (1≤m≤2⋅10^5) and k (1≤k≤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≤ℓ≤r≤n and 1≤x≤10^9.

输出格式

Output an integer indicating the total number of carrots.

输入样例 复制

5 5 3
1 1 3 4
2 2 4
1 1 2 3
1 4 5 3
2 1 4

输出样例 复制

5

分类标签