#P9053. [PA 2021] Ranking sklepów internetowych
[PA 2021] Ranking sklepów internetowych
Problem Description
You are given a permutation of length .
Define the weight of an interval as follows: sort the numbers in the interval in increasing order. Let be the interval length (that is, ), and let be the median of the interval. Then the weight of this interval is .
Among all intervals, find the maximum weight and the number of intervals whose weight equals this maximum.
Definition of the median:
Take a strictly increasing sequence of length as an example.
- If is odd, the median is .
- If is even, the median is .
Input Format
The first line contains an integer .
The second line contains integers .
Output Format
Output one line with two integers: the maximum weight and the number of intervals that achieve this maximum weight.
5
1 4 3 5 2
11 5
Hint
For of the testdata, , .
Translated by ChatGPT 5