PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000134. Nhuộm tất theo mẻ (Coloring Socks)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nhuộm tất theo mẻ (Coloring Socks)
Coloring Socks
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
There are socks, with color values . Each washing/dyeing batch may contain at most socks and must have maximum color minus minimum color at most . Every sock belongs to one batch. Minimize the number of batches.
Input
The first line has . The next line contains color values .
Output
Print the minimum number of batches.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
6 3 2
1 3 4 6 2 7
Output
3
Explanation
Sorted colors are . Groups , , and satisfy the capacity and color-spread conditions. Two groups cannot satisfy both.