Maximize The Value
시간 제한2초메모리 제한1024 MB
각 질의 (K,S,T)마다 [S,T] 안에서 연속한 연산 구간 l..r을 골라 위치 K에 더해지는 값의 최댓값을 구한다.
문제
You are given a one-based array consisting of integers: . Initially, the value of each element is set to .
There are operations (numbered from to ). Operation is represented by . If operation is executed, all elements for will be increased by .
You have to answer independent queries. Each query is represented by which represents the following task. Choose a range satisfying , and execute operations . The answer to the query is the maximum value of after the operations are executed among all possible choices of and .
입력
The first line consists of two integers ().
Each of the next lines consists of three integers (; ).
The following line consists of an integer ().
Each of the next lines consists of three integers (; ).
출력
For each query, output in a single line, an integer which represent the answer of the query.