#P8991. [北大集训 2021] 出题高手
[北大集训 2021] 出题高手
Background
CTT2021 D3T2
Problem Description
Alice is an expert at setting problems.
Alice sets one problem every day. After days, she has set problems.
On day , Alice does not set a new problem. She plans to choose some problems from the previous problems to form a contest. For convenience, she decides that the chosen problems must come from a continuous time interval, meaning they must be exactly all problems from day to day ().
Alice also gives each problem a rating. The rating of the -th problem is . A higher rating means the problem is more about IQ, while a lower rating means it is more about coding.
Alice wants the contest to have a distinctive style, i.e., overall leaning toward coding or overall leaning toward IQ. For a contest formed by all problems from day to day , its distinctiveness is defined as . Alice wants to maximize this distinctiveness.
Now, for queries of the form , you need to answer: if Alice is only allowed to choose problems from day to day , what is the maximum possible distinctiveness of the contest she can form? You need to output this value as a fraction.
Since Alice is far too good at setting problems, you may assume that the rating of each problem is randomly generated.
Input Format
The first line contains a positive integer .
The second line contains integers , representing Alice's rating for the problem set on day .
The third line contains a positive integer .
The next lines each contain two positive integers , representing a query.
Output Format
Output lines. Each line contains two integers with , indicating the answer is . If the answer is , then and .
5
-962 -445 -613 -9 920
3
1 5
3 5
1 3
4080400 3
846400 1
4080400 3
Hint
| Subtask | Score | ||
|---|---|---|---|
For Subtasks and , all queries satisfy and .
All satisfy . Also, for each , the testdata is generated by independently choosing an integer uniformly at random from each time.
Translated by ChatGPT 5