#P16563. [ICPC 2026 APC] Parallel Sums
[ICPC 2026 APC] Parallel Sums
题目描述
You are given two integers and . For a sequence of integers , the parallel sums of are the integers defined by for each ( ).
You are given the values of . Your task is to answer queries, described as follows. In the -th query, you are given two integers and , and you are asked to find the smallest possible value of among all sequences of integers (possibly negative) such that are the parallel sums of . Or determine if this value can be arbitrarily small.
输入格式
The first line of input contains two integers and ( ).
The second line contains integers ( ).
The third line contains a single integer ( ).
The -th of the next lines contains two integers and ( ).
输出格式
Output lines. The -th line should contain the smallest possible value of . If that value can be arbitrarily small, output unbounded instead.
8 4
4 -4 2 6 5
4
3 7
4 6
1 8
2 5
2
unbounded
4
-1
提示
Explanation for the sample input/output #1
For the first query, take . The parallel sums of are as required. Then $\max(a_3, \ldots, a_7) = \max(-3, 2, 1, 2, 1) = 2$ . It can be shown that is the smallest possible value.
For the second query, you can make the value arbitrarily small.
For the third query, take . Then , which is the smallest possible value.