CF360A.Levko and Array Recovery
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Levko loves array _a_1, _a_2, ... , a__n, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:
- Increase all elements from l__i to r__i by d__i. In other words, perform assignments a__j = a__j + d__i for all j that meet the inequation l__i ≤ j ≤ r__i.
- Find the maximum of elements from l__i to r__i. That is, calculate the value
.
Sadly, Levko has recently lost his array. Fortunately, Levko has records of all operations he has performed on array a. Help Levko, given the operation records, find at least one suitable array. The results of all operations for the given array must coincide with the record results. Levko clearly remembers that all numbers in his array didn't exceed 109 in their absolute value, so he asks you to find such an array.
莱夫科非常喜爱由整数构成的数组 a1,a2,…,an。正因如此,莱夫科常常对数组 a 进行各种操作。每次操作均为以下两种类型之一:
- 将下标从 li 到 ri 的所有元素增加 di。换言之,对所有满足不等式 li≤j≤ri 的 j,执行赋值操作 aj=aj+di。
- 求下标从 li 到 ri 的所有元素的最大值。即计算值
。
不幸的是,莱夫科最近丢失了他的数组。所幸的是,莱夫科保留了他在数组 a 上执行过的所有操作的完整记录。请根据这些操作记录,帮助莱夫科找出至少一个满足条件的数组:该数组在执行全部记录的操作时,每一步操作的结果(特别是类型 2 操作所求出的最大值)必须与记录完全一致。莱夫科清楚地记得,他原始数组中所有数的绝对值均不超过 109,因此他请求你找出这样一个数组。
输入格式
The first line contains two integers n and m (1 ≤ n, m ≤ 5000) — the size of the array and the number of operations in Levko's records, correspondingly.
Next m lines describe the operations, the i-th line describes the i-th operation. The first integer in the i-th line is integer t__i (1 ≤ t__i ≤ 2) that describes the operation type. If t__i = 1, then it is followed by three integers l__i, r__i and d__i (1 ≤ l__i ≤ r__i ≤ n, - 104 ≤ d__i ≤ 104) — the description of the operation of the first type. If t__i = 2, then it is followed by three integers l__i, r__i and m__i (1 ≤ l__i ≤ r__i ≤ n, - 5·107 ≤ m__i ≤ 5·107) — the description of the operation of the second type.
The operations are given in the order Levko performed them on his array.
第一行包含两个整数 n 和 m(1≤n,m≤5000),分别表示数组的大小以及 Levko 记录中的操作数量。
接下来的 m 行描述这些操作,其中第 i 行描述第 i 个操作。第 i 行的第一个整数为 ti(1≤ti≤2),表示操作类型。若 ti=1,则其后跟随三个整数 li、ri 和 di(1≤li≤ri≤n,−104≤di≤104),表示第一类操作;若 ti=2,则其后跟随三个整数 li、ri 和 mi(1≤li≤ri≤n,−5⋅107≤mi≤5⋅107),表示第二类操作。
这些操作按 Levko 在其数组上执行的顺序给出。
输出格式
In the first line print "YES" (without the quotes), if the solution exists and "NO" (without the quotes) otherwise.
If the solution exists, then on the second line print n integers _a_1, _a_2, ... , a__n (|a__i| ≤ 109) — the recovered array.
如果解存在,在第一行输出 "YES"(不带引号),否则输出 "NO"(不带引号)。
如果解存在,则在第二行输出 n 个整数 a1, a2, …, an(满足 ∣ai∣≤109)—— 即恢复出的数组。
输入输出样例
输入#1
4 5 1 2 3 1 2 1 2 8 2 3 4 7 1 1 3 3 2 3 4 8
输出#1
YES 4 7 4 7
输入#2
4 5 1 2 3 1 2 1 2 8 2 3 4 7 1 1 3 3 2 3 4 13
输出#2
NO
输入解题思路,AI测评打分。不知道怎么写?