#P10690. Fotile 模拟赛 L
Fotile 模拟赛 L
Problem Description
FOTILE is given a sequence of length . To save the Earth, he wants to know the maximum subarray sum within certain intervals.
That is, for each query, you need to compute
To reflect online operations, for a query :
- $l = \min ( ((x+{\rm lastans}) \bmod N)+1 , ((y+{\rm lastans}) \bmod N)+1)$.
- $r = \max ( ((x+{\rm lastans}) \bmod N)+1 , ((y+{\rm lastans}) \bmod N)+1)$.
Here is the answer to the previous query, and it is at the beginning.
Input Format
The first line contains two integers and .
The second line contains positive integers, where the -th number is , and there may be extra spaces.
The next lines each contain two numbers and , representing a query.
Output Format
Output lines. The -th line contains one positive integer, the answer to the -th query.
3 3
1 4 3
0 1
0 1
4 3
5
7
7
Hint
For all testdata, , , and , , and are all within the range of signed int.
Translated by ChatGPT 5