Logo
(追記) (追記ここまで)

18926번 - Histogram and Blue Rectangles 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB135595245.614%

문제

Consider an integer array $a$ of length $n$ where all $a_i$ are positive. Such an array may be represented as histogram. To draw the histogram, for each $i$ from 0 to $n-1$ we draw a blue rectangle with vertices $(i,0),ドル $(i,a_i),ドル $(i+1,a_i),ドル $(i+1,0)$.

The rectangle with the vertices at integer points is called \emph{covered} by the histogram, if the sides are parallel to the coordinate axes, and all the internal points of the rectangle are blue.

For each $j$ between 1 and $n$ calculate the maximal area of the rectangle covered by first $j$ columns of the given histogram.

입력

The first line of the input contains one integer $n$ (1ドル \le n \le 2 \cdot 10^5$), the length of the array $a$. The second line contains $n$ integers; the $i$-th of those integers represents $a_i$ (1ドル \le a_i \le 10^7$).

출력

Print $n$ integers, each on the new line. $i$-th of those integers is the maximal area of the rectangle covered by first $i$ columns of the given histogram.

제한

예제 입력 1

5
1 7 2 3 9

예제 출력 1

1
7
7
7
9

예제 입력 2

5
4 5 3 8 7

예제 출력 2

4
8
9
12
15

힌트

출처

Camp > Bytedance-Moscow Workshops Camp > Bytedance-Moscow Workshops Camp 2020 > Contest 1 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /