306686: CF1237D. Balanced Playlist
Memory Limit:512 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Balanced Playlist
题意翻译
## 题目描述 您最爱的音乐平台 Imakf 为您专门推出了一份完美平衡的歌单,共 $n$ 首曲子,编号从 $1$ 到 $n$。您听歌是列表循环的,所以说您听完第 $i$ 首歌后,下一首会播放第 $i + 1$ 首歌,听完最后一首歌后将会从头播放。 您根据自己的感觉,为每首歌估计了一个**KUN值**,第 $i$ 首歌的KUN值是 $a_i$. 每天早上您都会从一首歌开始听,听的过程中,您就会记住您已经听的歌中最大的KUN值是多少,记为 $x$。当您听到一首KUN值严格小于 $\dfrac{x}{2}$ 的歌曲时,您会立刻砸掉播放器,以保持每天的好心情。 久而久之,您就想知道对于每一首歌 $i$ ,如果从它开始听,到停止播放之前一共可以听多少首歌?一首歌如果被重复播放,那每一次都要统计。 ## 输入格式 第一行 $n (2\le n \le 10^5)$,表示歌单中的歌曲数量。 第二行共 $n$ 个整数 $a_1,a_2,...,a_n$ 表示每一首歌的KUN值。 ## 输出格式 一行共 $n$ 个整数,第 $i$ 个整数表示从第 $i$ 首歌开始听,到停止播放之前一共可以听多少首歌。题目描述
Your favorite music streaming platform has formed a perfectly balanced playlist exclusively for you. The playlist consists of $ n $ tracks numbered from $ 1 $ to $ n $ . The playlist is automatic and cyclic: whenever track $ i $ finishes playing, track $ i+1 $ starts playing automatically; after track $ n $ goes track $ 1 $ . For each track $ i $ , you have estimated its coolness $ a_i $ . The higher $ a_i $ is, the cooler track $ i $ is. Every morning, you choose a track. The playlist then starts playing from this track in its usual cyclic fashion. At any moment, you remember the maximum coolness $ x $ of already played tracks. Once you hear that a track with coolness strictly less than $ \frac{x}{2} $ (no rounding) starts playing, you turn off the music immediately to keep yourself in a good mood. For each track $ i $ , find out how many tracks you will listen to before turning off the music if you start your morning with track $ i $ , or determine that you will never turn the music off. Note that if you listen to the same track several times, every time must be counted.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 2 \le n \le 10^5 $ ), denoting the number of tracks in the playlist. The second line contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 1 \le a_i \le 10^9 $ ), denoting coolnesses of the tracks.
输出格式
Output $ n $ integers $ c_1, c_2, \ldots, c_n $ , where $ c_i $ is either the number of tracks you will listen to if you start listening from track $ i $ or $ -1 $ if you will be listening to music indefinitely.
输入输出样例
输入样例 #1
4
11 5 2 7
输出样例 #1
1 1 3 2
输入样例 #2
4
3 2 5 3
输出样例 #2
5 4 3 6
输入样例 #3
3
4 3 6
输出样例 #3
-1 -1 -1