CF295A.Greg and Array

普及/提高-

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Greg has an array a = _a_1, _a_2, ..., a__n and m operations. Each operation looks as: l__i, r__i, d__i, (1 ≤ l__i ≤ r__i ≤ n). To apply operation i to the array means to increase all array elements with numbers l__i, l__i + 1, ..., r__i by value d__i.

Greg wrote down k queries on a piece of paper. Each query has the following form: x__i, y__i, (1 ≤ x__i ≤ y__i ≤ m). That means that one should apply operations with numbers x__i, x__i + 1, ..., y__i to the array.

Now Greg is wondering, what the array a will be after all the queries are executed. Help Greg.

Greg 有一个数组 a=a1,a2,…,ana = a_1, a_2, \dots, a_n 和 mm 个操作。每个操作形如:li,ri,dil_i, r_i, d_i(其中 1≤li≤ri≤n1 \le l_i \le r_i \le n)。对数组执行第 ii 个操作,是指将数组中下标为 li,li+1,…,ril_i, l_i+1, \dots, r_i 的所有元素均增加 did_i。

Greg 在纸上写下了 kk 个查询。每个查询形如:xi,yix_i, y_i(其中 1≤xi≤yi≤m1 \le x_i \le y_i \le m),表示应依次执行编号为 xi,xi+1,…,yix_i, x_i+1, \dots, y_i 的所有操作。

现在 Greg 想知道:在执行完全部查询后,数组 aa 将变成什么样子?请帮助 Greg。

输入格式

The first line contains integers n, m, k (1 ≤ n, m, k ≤ 105). The second line contains n integers: _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 105) — the initial array.

Next m lines contain operations, the operation number i is written as three integers: l__i, r__i, d__i, (1 ≤ l__i ≤ r__i ≤ n), (0 ≤ d__i ≤ 105).

Next k lines contain the queries, the query number i is written as two integers: x__i, y__i, (1 ≤ x__i ≤ y__i ≤ m).

The numbers in the lines are separated by single spaces.

第一行包含整数 nn、mm、kk(1 ≤ n, m, k ≤ 1051 ≤ n, m, k ≤ 10^5)。第二行包含 nn 个整数:a1, a2, ..., ana_1, a_2, ..., a_n(0 ≤ ai ≤ 1050 ≤ a_i ≤ 10^5)—— 初始数组。

接下来 mm 行描述操作,第 ii 个操作以三个整数形式给出:lil_i, rir_i, did_i(其中 1 ≤ li ≤ ri ≤ n1 ≤ l_i ≤ r_i ≤ n,0 ≤ di ≤ 1050 ≤ d_i ≤ 10^5)。

接下来 kk 行描述查询,第 ii 个查询以两个整数形式给出:xix_i, yiy_i(其中 1 ≤ xi ≤ yi ≤ m1 ≤ x_i ≤ y_i ≤ m)。

每行中的数字以单个空格分隔。

输出格式

On a single line print n integers _a_1, _a_2, ..., a__n — the array after executing all the queries. Separate the printed numbers by spaces.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.

在一行中输出 nn 个整数 a1, a2, …, ana_1,\ a_2,\ \dots,\ a_n —— 执行完所有查询后的数组。各输出数字之间用空格分隔。

请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符。推荐使用 cin、cout 流,或 %I64d 说明符。

输入输出样例

  • 输入#1

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

    输出#1

    9 18 17
  • 输入#2

    1 1 1
    1
    1 1 1
    1 1

    输出#2

    2
  • 输入#3

    4 3 6
    1 2 3 4
    1 2 1
    2 3 2
    3 4 4
    1 2
    1 3
    2 3
    1 2
    1 3
    2 3

    输出#3

    5 18 31 20

输入解题思路,AI测评打分。不知道怎么写?

首页