CF57B.Martian Architecture
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Chris the Rabbit found the traces of an ancient Martian civilization. The brave astronomer managed to see through a small telescope an architecture masterpiece — "A Road to the Sun". The building stands on cubical stones of the same size. The foundation divides the entire "road" into cells, into which the cubical stones are fit tightly. Thus, to any cell of the foundation a coordinate can be assigned. To become the leader of the tribe, a Martian should build a Road to the Sun, that is to build from those cubical stones on a given foundation a stairway. The stairway should be described by the number of stones in the initial coordinate and the coordinates of the stairway's beginning and end. Each following cell in the coordinate's increasing order should contain one cubical stone more than the previous one. At that if the cell has already got stones, they do not count in this building process, the stairways were simply built on them. In other words, let us assume that a stairway is built with the initial coordinate of l, the final coordinate of r and the number of stones in the initial coordinate x. That means that x stones will be added in the cell l, x + 1 stones will be added in the cell l + 1, ..., x + r - l stones will be added in the cell r.
Chris managed to find an ancient manuscript, containing the descriptions of all the stairways. Now he wants to compare the data to be sure that he has really found "A Road to the Sun". For that he chose some road cells and counted the total number of cubical stones that has been accumulated throughout the Martian history and then asked you to count using the manuscript to what the sum should ideally total.
克里斯这只兔子发现了古代火星文明的遗迹。这位勇敢的天文学家通过一架小型望远镜,目睹了一座建筑杰作——“通向太阳之路”。该建筑建于若干大小完全相同的立方体石块之上。其地基将整条“路”划分为若干格子,立方体石块被严丝合缝地嵌入其中。因此,地基上的每个格子均可赋予一个坐标。火星人若想成为部落首领,就必须建造一条“通向太阳之路”,即在给定地基上用这些立方体石块搭建一座阶梯状结构。该阶梯结构由起始坐标的石块数、阶梯起始坐标与终止坐标共同描述:在坐标递增的方向上,每个后续格子中的石块数比前一个格子多一块;且若某格子中已存在石块,则这些已有石块不计入本次建造过程——新石块是直接堆叠在其上的。换言之,设某阶梯结构的起始坐标为 l,终止坐标为 r,起始坐标处新增石块数为 x,则表示在坐标 l 处新增 x 块石块,在坐标 l+1 处新增 x+1 块石块,……,在坐标 r 处新增 x+r−l 块石块。
克里斯成功找到了一份古代手稿,其中记载了所有此类阶梯结构的建造信息。现在他希望将手稿数据与实地观测结果进行比对,以确认自己是否真正发现了“通向太阳之路”。为此,他选取了道路中若干格子,并统计了整个火星历史上这些格子中累积的立方体石块总数;接着,他请你根据手稿内容,计算出这些格子中石块数的理想理论总和。
输入格式
The first line contains three space-separated integers: n, m, k (1 ≤ n, m ≤ 105, 1 ≤ k ≤ min(n, 100)) which is the number of cells, the number of "Roads to the Sun" and the number of cells in the query correspondingly. Each of the following m roads contain three space-separated integers: a__i, b__i, c__i (1 ≤ a__i ≤ b__i ≤ n, 1 ≤ c__i ≤ 1000) which are the stairway's description, its beginning, end and the initial cell's height. Then follow a line, containing k different space-separated integers b__i. All these numbers ranging from 1 to n are cells, the number of stones in which interests Chris.
第一行包含三个用空格分隔的整数:n、m、k(其中 1≤n,m≤105,1≤k≤min(n,100)),分别表示单元格总数、“通往太阳之路”的数量以及查询中涉及的单元格数量。接下来的 m 行每行包含三个用空格分隔的整数:ai、bi、ci(其中 1≤ai≤bi≤n,1≤ci≤1000),描述一条楼梯:ai 为其起始单元格编号,bi 为其终止单元格编号,ci 为起始单元格的初始高度。随后一行包含 k 个互不相同的、用空格分隔的整数 bi。这些数均在 1 到 n 范围内,表示 Chris 关心其石子数量的单元格编号。
输出格式
You have to print a single number on a single line which is the sum of stones in all the cells Chris is interested in.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).
你需要在单独的一行上输出一个数字,该数字为克里斯感兴趣的全部格子中石头数量的总和。
请注意,在 C++ 中读取或写入 64 位整数时,请勿使用 %lld 格式说明符。推荐使用 cin(你也可以使用 %I64d)。
输入输出样例
输入#1
5 2 1 1 5 1 2 4 1 3
输出#1
5
输入#2
3 2 1 1 3 1 1 3 1 2
输出#2
4
输入#3
3 2 1 1 3 1 1 3 1 3
输出#3
6
输入解题思路,AI测评打分。不知道怎么写?