-->
当前位置:首页 > 题库

PROGRAMMING:Interval 1

Luz5年前 (2021-05-10)题库471
Keven now has a simple problem. He thinks it's very simple, so he wants to test you.
The main idea of the title is as follows:
It is known that there is a sequence of length N, and K operations are performed on this sequence,
Each operation gives three numbers L, R and Val, which means that all the numbers in the interval L-R are changed into val.
After K operations, the sum of all the numbers in the interval '1-N' is output.
###Input format:
In the first line, the two numbers N and K (n < 200000, K < 200000) indicate the sequence length (sequence subscript starts from 1) and the number of operations.
The second line gives n numbers( Ensure each number < 1e8)
Then K lines, each line has three numbers L, R, val( L<=N,R<=N,val<1e8)
###Output format:
Output the sum of all the numbers in the interval '1-N' in one line.
###Input example:
```in
10 2
10 9 8 7 6 5 4 3 2 1
1 5 2
5 9 3
```
###Output example:
```out
twenty-four
```
###Tips
The final value of the sample interval is' 2 2 3 3 3 1 ', so the answer is' 24'


answer:If there is no answer, please comment