#CT00049. Ghép đội (Team Matching)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Ghép đội (Team Matching)
Team Matching
Version: Phuoc Hung OJ Extended
Problem Statement
There are two groups of students, and . Group has students with scores ; group has students with scores .
A team consists of exactly one student from each group. A pair with scores may be formed if . Each student may belong to at most one team.
Find the maximum number of teams.
Input
The first line contains .
The second line contains integers .
The third line contains integers .
Output
Print one integer: the maximum number of teams.
Subtasks
, .
- Subtask 1 (30 points): .
- Subtask 2 (30 points): ; both arrays are nondecreasing.
- Subtask 3 (40 points): .
Examples
Example 1
Input
5 6 2
1 4 7 10 12
2 3 6 8 11 15
Output
4
Explanation
With , pair scores , , , and ; the differences are . The remaining and differ by , yielding four teams.
Example 2
Input
4 4 0
1 2 2 5
2 2 3 5
Output
3
Explanation
With , paired scores must be equal. Two students with score and one with score can be paired, giving teams. Scores and remain unmatched.
Example 3
Input
3 3 1
10 20 30
1 2 3
Output
0
Explanation
All group- scores are at least , while all group- scores are at most . No pair can satisfy , so the answer is zero.
Liên quan
Trong các cuộc thi sau: