#C1783. Maximum Beauty of Subarrays
Maximum Beauty of Subarrays
Maximum Beauty of Subarrays
You are given an array of n integers. For any subarray, its beauty is defined as the maximum element in that subarray. For each possible subarray length m (where 1 \( \le m \le n \)), determine the maximum beauty among all subarrays of that length.
Observation: Since the maximum element of the entire array will appear in every subarray that contains it, the answer for every subarray length is simply the maximum element of the array. In other words, if \( M \) is the maximum element, then the answer for each subarray length is \( M \).
For example, if the array is [1, 3, 2, 4, 5], then the maximum element is 5, so the answer for every subarray length will be 5.
inputFormat
The input consists of two lines:
- The first line contains a single integer n (1 \( \le n \le 10^5 \)), denoting the number of elements in the array.
- The second line contains n space-separated integers, representing the elements of the array.
outputFormat
Output a single line containing n space-separated integers. Each integer represents the maximum beauty for a subarray length from 1 to n. Since every subarray length will have the same maximum beauty, the output will be the maximum element repeated n times.
## sample5
1 3 2 4 5
5 5 5 5 5