Game of Rounding
Time limit2sMemory limit1024 MB
For each start level l, find the segment starting at l whose rounded average is maximal, and report the shortest length that reaches it.
- Level
Medium7 of 10
- Topics
- Prefix sum, Divide and conquer, Sorting
- Solved
- No attempts yet
Problem
Jack got a new video game called "Rounding" with levels. The game has a global ranking system that ranks all players worldwide by their scores. Jack wants to break the global record and show everyone he is the master of this game, so he studied the scoring system closely.
He finally understands the scoring rules. Each time a player finishes a level, they earn some points. A player's score is the average points per level, rounded to the nearest whole number. More precisely, if a player plays levels and earns points, the score is . For example, if a player earns points in 3 levels, the score is .
Jack has practiced several times and knows the points he will earn in level . He found an exploit that lets him skip some levels at the beginning and stop at any time. So Jack can choose a pair with and play only levels through .
For each starting level with , Jack wants to know the maximum score he can achieve and how many levels he should play to reach it. If several choices give the maximum score, he should report the smallest number of levels, since playing for a long time is unhealthy.
Input
The first line contains an integer , the number of test cases. Each test case consists of two lines. The first line contains an integer , the number of levels. The second line contains space-separated integers , the points earned in each level.
Output
For each test case, output integers on one line. The -th number is the number of levels Jack should play, starting from level , to achieve the maximum score. If several choices achieve the maximum score, print the smallest number of levels.
Constraints
for .
The sum of over all test cases is at most .