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

21201번 - Interview Queue 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB104262426.087%

문제

A very popular position has just opened up at Poodle Inc. Candidates have formed a queue while they wait for their turn to be interviewed.

Competition is fierce and each candidate knows that they will not be selected if another candidate is strictly better than them. Every minute, each candidate looks at the resumé of candidates who are currently adjacent to them in the queue (ahead and behind). If at least one of the neighbour's resumé's perceived value is strictly greater than their resumé's perceived value, they leave the queue since they do not want to waste their time. The candidates all look at their neighbor's resumé simultaneously, and then some candidates leave the queue simultaneously.

This process continues until no more candidates leave the queue. Determine the number of minutes that pass while this process takes place. Report the values of the candidates that leave the queue in each round. Also report the final state of the queue.

입력

The first line of input contains a single integer $N$ (1ドル \leq N \leq 100,000円$), which is the number of candidates.

The second line contains $N$ integers $v_1, \ldots, v_N$ (0ドル \leq v_i \leq 10^9$ for each 1ドル \leq i \leq N$), where $v_i$ is the perceived value of the $i^\textrm{th}$ candidate.

출력

Display $M,ドル the number of minutes taken by this process. Then display $M$ lines. The $i^\textrm{th}$ line should contain the perceived values of the candidates who left the queue in the $i^\textrm{th}$ minute in the same relative order that they appeared in the queue. Finally display a line indicating the final list of perceived values in the queue after candidates no longer leave it.

제한

예제 입력 1

10
3 6 2 3 2 2 2 1 5 6

예제 출력 1

2
3 2 2 1 5
3 2 2
6 6

예제 입력 2

3
17 17 17

예제 출력 2

0
17 17 17

예제 입력 3

7
8 1 2 3 5 6 7

예제 출력 3

2
1 2 3 5 6
7
8

힌트

출처

ICPC > Regionals > North America > Rocky Mountain Regional > 2020 Rocky Mountain Regional Contest E번

  • 문제를 만든 사람: Zachary Friggstad
(追記) (追記ここまで)

출처

대학교 대회

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

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