Game of Rounding

시간 제한2초메모리 제한1024 MB

요약
각 시작 레벨마다 얻는 점수의 반올림 평균이 최대가 되도록 플레이할 최소 연속 레벨 수를 구한다.
난이도

어려움10점 중 8점

유형
배열, 이분 탐색, 그리디, 누적 합
정답자
아직 제출이 없습니다

문제

Jack got a new video game called “Rounding,” which contains nn levels. The game features a global ranking system that ranks all players worldwide based on their scores. Jack wants to break the global record and let everyone know who the master of this game is, so he has investigated the scoring system extensively.

He finally understands the scoring rules: when a player finishes each level, they earn some points. The player’s score is the average points they earn per level, rounded to the nearest whole number. More precisely, if a player plays a total of kk levels and earns p_1,p_2,…,p_kp\_1, p\_2,\dots ,p\_k points respectively, their score will be ⌊∑_i=1kp_ik+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 33 levels, their score will be ⌊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 a_ia\_i he will earn in the ii-th level. He discovered an exploit in the game that allows him to skip some levels at the beginning and stop at any time. This means Jack can choose a pair of numbers (l,r)(l, r) where 1≤l≤r≤n1 ≤ l ≤ r ≤ n, and only play the levels from ll to rr.

Jack is curious about the maximum score he can achieve for each starting level ll for 1≤l≤n1 ≤ l ≤ n, and how many levels he should play to achieve that maximum score. If there are several answers that yield the maximum score, he should print the smallest number of levels, as playing the game for a long time is unhealthy.

입력

The frst line contains an integer tt, indicating the number of test cases. Each test case consists of two lines. The first one contains an integer nn, indicating the number of levels in the video game. The second one contains nn space-separated integers, a_1,a_2,…,a_na\_1, a\_2,\dots ,a\_n, representing the points Jack will earn in each level.

출력

For each test case, output nn integers in one line. The ii-th number indicates the number of levels Jack should play, starting from level ii, to achieve the maximum score. If there are several answers that achieve the maximum score, print the smallest number of levels.

제한

  • 1≤t≤1051 ≤ t ≤ 10^5
  • 1≤n≤2×1051 ≤ n ≤ 2 \times 10^5
  • 0≤a_i≤1090 ≤ a\_i ≤ 10^9 for i∈1,2,…,ni \in \\{1, 2,\dots ,n\\}.
  • The sum of nn’s of all test cases is at most 2×1052 \times 10^5.

예제1

  1. 예제 1

    입력
    3
    3
    1 3 3
    4
    1 2 3 4
    5
    2 3 2 3 3
    
    예상 출력
    2 1 1
    4 2 2 1
    2 1 2 1 1