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

31271번 - Milano C.le 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB41302573.529%

문제

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_i$/$b_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.

입력

The first line contains an integer $n$ (1ドル ≤ n ≤ 2 \cdot 10^5$), the number of trains.

The second line contains $n$ integers $a_i,ドル (1ドル ≤ a_i ≤ n,ドル $a_i \ne a_j$ for all $i \ne j$), which denote that the $i$-th train arrives at the station as the $a_i$-th train on the first day. The sequence $(a_i)$ is a permutation.

The third line contains $n$ integers $b_i,ドル (1ドル ≤ b_i ≤ n,ドル $b_i \ne b_j$ for all $i \ne j$), which denote that the $i$-th train leaves the station as the $b_i$-th train on the second day. The sequence $(b_i)$ is a permutation.

출력

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

제한

서브태스크

번호배점제한
121

$n ≤ 10$

218

The minimum number of platforms needed will be either 1ドル$ or 2ドル$.

331

$n ≤ 1,円 000$

440

No additional constraints.

예제 입력 1

5
3 5 2 4 1
3 2 5 1 4

예제 출력 1

2

예제 입력 2

5
3 1 2 5 4
4 2 3 1 5

예제 출력 2

4

예제 입력 3

3
3 2 1
1 2 3

예제 출력 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.

출처

Contest > Croatian Open Competition in Informatics > COCI 2023/2024 > Contest #3 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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