#TP0000024. Điều chỉnh đề thi (Contest Proposal)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Điều chỉnh đề thi (Contest Proposal)
Contest Proposal
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A programming contest must contain exactly problems. The desired upper bound for the difficulty of problem is . The existing proposals have difficulties . Both arrays and are initially sorted in non-decreasing order.
The organizers may repeatedly choose a positive integer , insert a proposed problem of difficulty , sort all proposals, and delete one with the greatest difficulty. Exactly proposals remain after each operation. Find the minimum number of operations needed to achieve at every position .
Input
- The first line contains , the number of contest problems.
- The second line contains integers in non-decreasing order.
- The third line contains integers in non-decreasing order, the desired upper bounds at each position.
Output
Print one integer: the minimum number of new proposals needed.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
6
1000 1400 2000 2000 2200 2700
800 1200 1500 1800 2200 3000
Output
2
Explanation
Insert a problem of difficulty and delete the most difficult one, , obtaining . Then insert and remove , obtaining . Every entry now satisfies its corresponding bound in . One operation cannot be sufficient because at least two proposals cannot be retained in a valid final array; hence the answer is .