#P9681. 幽默的世界。
幽默的世界。
Background
@【data deleted】: What do you all think? || @【data deleted】: OI life is always full of humor. But maybe studying school subjects is not much better?
Problem Description
Given a sequence of length , define a contiguous subsequence to be humorous if and only if:
- ;
- For all , we have .
There are queries. In each query, you are given two integers , and you need to count the number of pairs that satisfy:
- ;
- The contiguous subsequence is humorous.
Input Format
The first line contains two integers .
The next line contains integers, where the -th integer is .
The next lines each contain two integers , representing a query.
Output Format
For each query, output one integer per line, which is the answer.
4 3
3 -4 -1 2
1 2
3 4
1 4
1
2
3
7 6
-1 2 -1 -1 -1 2 -1
2 5
4 7
1 7
5 5
1 3
2 4
1
2
4
0
2
1
Hint
For all testdata, it is guaranteed that , , and .
Subtasks
| # | Special Property | Score |
|---|---|---|
| 0 | Sample | 0 |
| 1 | 15 | |
| 2 | 20 | |
| 3 | For all queries, | 15 |
| 4 | For all queries, | |
| 5 | - | 35 |
Translated by ChatGPT 5