시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB744418.182%

문제

N students are sitting in a row, taking an exam. They are numbered from left to right with integers starting from 1. It is known how good each student’s work is: i-th student is going to score exactly Ai points.

Sometimes the proctor leaves for a break and when that happens students can cheat: any two or more consecutive students can gather and copy the best work among them. As a result, their scores become equal to the maximum score in that interval. Cheating can happen arbitrarily many (possibly zero) times.

In order to pass the exam i-th student needs to score exactly Bi points. Determine the maximum number of students that can pass the exam.

입력

In the first line of the input there is an integer N.

In the next line there are N integers: A1, A2, ..., AN.

In the next line there are N integers: B1, B2, …, BN.

출력

You should print exactly one integer: the maximum number of students.

제한

  • 2 ≤ N
  • 1 ≤ Ai ≤ 109
  • 1 ≤ Bi ≤ 109

서브태스크

번호배점제한
114

N ≤ 10

212

N ≤ 105, All elements of B are equal (B1 = B2 = ⋯ = Bn)

313

N ≤ 5000, A is strictly increasing (A1 < A2 < ⋯ < An)

423

N ≤ 105, All elements of A are distinct

516

N ≤ 200

622

N ≤ 5000

예제 입력 1

3
1 2 3
2 2 2

예제 출력 1

2

예제 입력 2

4
10 1 9 1
10 9 10 9

예제 출력 2

3

힌트

In the first example the first two students can cheat after which the scores becomes 2,2,3 and they both pass the exam.

In the second example students 2 and 3 can pass the exam but not both at the same time. Note that this test can’t be present in subtasks 2,3 or 4.

채점 및 기타 정보

  • 예제는 채점하지 않는다.