포럼
문제 ICPC00181

A. Ascending Photo

설명

The members of the No-Weather-too-Extreme Recreational Climbing society completed their 100th successful summit today! To commemorate the occasion, we took a picture of all the members standing together in one row, to use for marketing purposes.

However, the photograph looks messy; as usual, the members refused to order themselves in any kind of aesthetically pleasing way. We will need to reorder the picture.

Our research tells us that having the climbers in ascending (non-decreasing) height order from left to right will be most visually appealing. We must cut up the picture we have and somehow paste it back together in this order.

Find the minimum number of cuts you need to make to put the photograph into ascending order.

제약
입력 형식

The input consists of:
- One line with an integer \(n\) (\(1 \leq n \leq 10^6 \)), the number of people in the photo.
- One line with \(n\) integers \(h_1, \ldots, h_n\) (\(1 \leq h_i \leq 2 \cdot 10^9\) for each \(i\)), the heights of the people in the photograph, from left to right.

출력 형식

Output the minimum number of cuts needed to rearrange the photograph into any one ascending (non-decreasing) height order from left to right.

예제 1
입력
11
3 6 12 7 7 7 7 8 10 5 5
출력
4
예제 2
입력
3
5000000 5500000 7000000
출력
0
예제 3
입력
12
1 2 2 3 3 1 2 3 4 1 2 3
출력
6
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2017

평가 및 의견

A. Ascending Photo

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

A. Ascending Photo

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8