PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000070. Ghép cặp điểm xa nhau (Match Points)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ghép cặp điểm xa nhau (Match Points)
Match Points
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given points on a number line, possibly with equal coordinates, form the maximum number of disjoint pairs such that each pair has distance at least .
Input
Line 1: . Line 2: integer coordinates.
Output
Print the maximum number of disjoint valid pairs.
Subtasks
- Subtask 1 (20 points): Exactly one dataset; ; ; point coordinates may be equal.
- Subtask 2 (30 points): Exactly one dataset; ; ; point coordinates may be equal.
- Subtask 3 (50 points): Exactly one dataset; ; ; point coordinates may be equal.
Example
Input
4 2
1 3 3 7
Output
2
Explanation
After sorting, pair 1 with 3 and the other 3 with 7, obtaining two disjoint pairs.