RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00583

Po

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Tinky Winky left a sequence of \(n\) zeroes in the Tubbytronic Superdome, and left for a walk
with Dipsy. When he came back, he saw that a misdeed has been done. The sequence was
changed, and Po was smiling mischeviously in the corner of the room.
\(Oh\) dear! Po, what have you done?! – asked Tinky Winky in horror.
\(I\) enhanced the sequence! – replied Po.
After cro\(ss-ex\)amination, it was established that Po did a number of enhancements on the sequence. In
every enhancement, she took a segment of a sequence and increased all elements in the segment by
some positive integer. Also, every two segments were either disjoint or one was completely contained in
other.
How many enhancements have you done, Po? – L\(aa-La\)a inquired.
\(I\) really don’t know! I’m only sure \(I\) did the minimum number \(of\) enhancements possible \(to\) get this
sequence! – said Po exhaustedly.
Then \(it\) surely must \(be\) \(m\)! – proclaimed N\(oo-No\)o. ^{1}
What number did N\(oo-No\)o say?

제약

In test cases worth 30 points, it holds \(1 \le n \le 1000\).

입력 형식

The first line contains an integer \(n\) (\(1 \le n \le 100\,000\)), the length of the sequence.
The second line contains \(n\) nonnegative integers \(a_{i}\) (\(0 \le a_{i} \le 10^{9}\)), the sequence after Po’s enhancements.

출력 형식

Output \(m\), the minimum possible number of enhancements.

예제 1
입력
3
2 2 2
출력
1
예제 2
입력
5
2 3 3 3 2
출력
2
예제 3
입력
6
1 2 3 2 1 3
출력
4
설명

Clarification of the second example:
Po first increased all elements of the sequence by 2, and then increased the middle three by 1.
1Noo-Noo is the Teletubies’ vacuum cleaner pet.

문제 정보

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

출처 COCI 2020/2021 Contest 5

평가 및 의견

Po

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

Log in to rate problems.

개별 의견

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

풀이 제출

Po

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