CF1906F.Maximize The Value
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a one-based array consisting of N integers: A1,A2,⋯,AN . Initially, the value of each element is set to 0 .
There are M operations (numbered from 1 to M ). Operation i is represented by ⟨Li,Ri,Xi⟩ . If operation i is executed, all elements Aj for Li≤j≤Ri will be increased by Xi .
You have to answer Q independent queries. Each query is represented by ⟨K,S,T⟩ which represents the following task. Choose a range [l,r] satisfying S≤l≤r≤T , and execute operations l,l+1,…,r . The answer to the query is the maximum value of AK after the operations are executed among all possible choices of l and r .
输入格式
The first line consists of two integers N M ( 1≤N,M≤100000 ).
Each of the next M lines consists of three integers Li Ri Xi ( 1≤Li≤Ri≤N;−100000≤Xi≤100000 ).
The following line consists of an integer Q ( 1≤Q≤100000 ).
Each of the next Q lines consists of three integers K S T ( 1≤K≤N;1≤S≤T≤M ).
输出格式
For each query, output in a single line, an integer which represent the answer of the query.
输入输出样例
输入#1
2 6 1 1 -50 1 2 -20 2 2 -30 1 1 60 1 2 40 2 2 10 5 1 1 6 2 1 6 1 1 3 2 1 3 1 1 2
输出#1
100 50 0 0 -20
输入#2
5 3 1 3 3 2 4 -2 3 5 3 6 1 1 3 2 1 3 3 1 3 3 2 3 2 2 3 2 2 2
输出#2
3 3 4 3 0 -2
说明/提示
Explanation for the sample input/output #1
For query 1 , one of the solutions is to execute operation 4 and 5 .
For query 2 , one of the solutions is to execute operation 4 , 5 , and 6 .
For query 3 , the only solution is to execute operation 3 .
For query 4 , the only solution is to execute operation 1 .
For query 6 , the only solution is to execute operation 2 .