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

Milano C.le

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

의견: 0

설명

Silvia is at the Milano Centrale railway station and she noticed
that the station has a lot of platforms. She thought that there
are too many of them, so she decided to check how many of
them are actually needed.
Silvia also noticed an interesting fact that holds at this station:
the schedule of arrivals and departures repeats every two days, and additionally, the schedule is such that
all \(n\) trains arrive at the station on one day, and leave the station on the other day. Note that in this way
no train will leave before all trains have arrived.
The platforms at the station are long enough so that all \(n\) trains can be lined up one after another on the
same platform. However, if train \(x\) enters the platform first, and then train \(y\), then train \(x\) cannot leave
the platform before train \(y\).
The illustration shows \(a\) possible train schedule \(on\) the platforms \(in\) the second sample test.
The labels \(on\) the train ’\(i\) : \(a@@RISE_MATH_BLOCK_0@@i\)’ denote that the \(i-th\) train will arrive \(a\)\(i-th\) \(at\) the station \(on\) the first day,
and leave the station \(b_{i}-th\) \(on\) the second day.
The train (2 : \(1/2\)) cannot leave the platform before the train (4 : \(5/1\)).
Silvia is interested in what is the minimum number of platforms needed so that all trains can be lined up
on the platforms, without the possibility that a train cannot leave the platform because there is a train in
front of it that has not yet left.

제약

Subtask 1 (21 points): \(n \le 10\)

Subtask 2 (18 points): The minimum number of platforms needed will be either 1 or 2.

Subtask 3 (31 points): \(n \le 1\,000\)

Subtask 4 (40 points): No additional constraints.

입력 형식

The first line contains an integer \(n\) (\(1 \le n \le 2 \cdot 10^{5}\)), the number of trains.
The second line contains \(n\) integers \(a_{i}\), (\(1 \le a_{i} \le n\), \(a_{i}\)̸ = \(a_{j}\) for all \(i\)̸ = \(j\)), which denote that the \(i-th\) train
arrives at the station as the \(a@@RISE_MATH_BLOCK_0@@i\)) is a permutation.
The third line contains \(n\) integers \(b@@RISE_MATH_BLOCK_1@@i \le n\), \(b@@RISE_MATH_BLOCK_2@@j\) for all \(i\)̸ = \(j\)), which denote that the \(i-th\) train
leaves the station as the \(b@@RISE_MATH_BLOCK_3@@i\)) is a permutation.

출력 형식

In the first and only line you should output the minimum number of platforms needed.

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

Clarification of the second example:
Take a look at the illustration in the statement.
Clarification of the third example:
All the trains can be lined up on the same platform without any problems.

문제 정보

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

출처 COCI 2023/2024 Contest 3

평가 및 의견

Milano C.le

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

Log in to rate problems.

개별 의견

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

풀이 제출

Milano C.le

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