Under construction

Still being built. Things may change

Game of Rounding

Time limit2sMemory limit1024 MB

Summary
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 nn 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 kk levels and earns p1,p2,…,pkp_1, p_2, \dots, p_k points, the score is ⌊∑i=1kpik+0.5⌋\left\lfloor \frac{\sum_{i=1}^k{p_i}}{k} + 0.5\right\rfloor. For example, if a player earns [2,3,3][2, 3, 3] points in 3 levels, the score is ⌊2+3+33+0.5⌋=3\left\lfloor \frac{2+3+3}{3} + 0.5\right\rfloor = 3.

Jack has practiced several times and knows the points aia_i he will earn in level ii. He found an exploit that lets him skip some levels at the beginning and stop at any time. So Jack can choose a pair (l,r)(l, r) with 1≤l≤r≤n1 \le l \le r \le n and play only levels ll through rr.

For each starting level ll with 1≤l≤n1 \le l \le n, 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 tt, the number of test cases. Each test case consists of two lines. The first line contains an integer nn, the number of levels. The second line contains nn space-separated integers a1,a2,…,ana_1, a_2, \dots, a_n, the points earned in each level.

Output

For each test case, output nn integers on one line. The ii-th number is the number of levels Jack should play, starting from level ii, to achieve the maximum score. If several choices achieve the maximum score, print the smallest number of levels.

Constraints

1≤t≤1051 \le t \le 10^5

1≤n≤2×1051 \le n \le 2 \times 10^5

0≤ai≤1090 \le a_i \le 10^9 for i∈{1,2,…,n}i \in \{1, 2, \dots, n\}.

The sum of nn over all test cases is at most 2×1052 \times 10^5.

Examples1

  1. Example 1

    Input
    3
    3
    1 3 3
    4
    1 2 3 4
    5
    2 3 2 3 3
    
    Expected output
    2 1 1
    4 2 2 1
    2 1 2 1 1