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

S3. Gates

설명

For your birthday, you were given an airport.

The airport has \(G\) gates,
numbered from 1 to \(G\).

\(P\) planes arrive at the airport,
one after another. You are to assign the \(i\)th plane to permanently dock at any gate
\(1,\ldots, g_i~(1 \leq g_i \leq G)\), at which no previous
plane has docked. As soon as a plane cannot dock at any gate, the
airport is shut down and no future planes are allowed to arrive.

In order to keep the person who gave you the airport happy, you would
like to maximize the number of planes starting from the beginning that
can all dock at different gates.

제약
입력 형식

The first line of input contains \(G~(1 \leq G \leq 10^5)\), the number of gates at the airport.

The second line of input contains \(P~(1 \leq P \leq 10^5)\), the number of planes which will land.

The next \(P\) lines contain one
integer \(g_i~(1 \leq g_i \leq G)\), such that the \(i\)th plane must dock at some gate from
\(1\) to \(g_i\), inclusive.

Note that for at least 40% of the marks for this question, \(P \leq 2000\) and \(G \leq 2000\).

출력 형식

Output the maximum number of planes that can land starting from the
beginning.

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

The first plane can go anywhere, but it is best to not put it into
Gate 1. Notice that planes 2 and 3 both want to dock into Gate 1, so
plane 3 is unable to dock.

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

The first two planes will dock in gates 1 and 2 (in any order). The
third plane must dock at Gate 3. Thus, the fourth plane cannot dock
anywhere, and the airport is closed, even though plane 5 would have been
able to dock.

문제 정보

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

출처 CCC 2015 Senior

평가 및 의견

S3. Gates

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

Log in to rate problems.

개별 의견

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

풀이 제출

S3. Gates

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