#BS0000319. Cân bằng công suất (Low Power)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cân bằng công suất (Low Power)
Low Power
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
There are n machines, each with two chips, and each chip requires exactly k batteries. Assign all 2nk batteries exactly once. A chip’s output is the minimum of its k battery outputs. Minimize the maximum absolute difference between the two chip outputs of any machine.
Input
- The first line contains integers , the number of machines and the number of batteries per chip.
- The second line contains exactly integers , the battery outputs.
Output
Print one integer: the minimum possible maximum difference between the two chip outputs of a machine.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input 1
2 3
1 2 3 4 5 6 7 8 9 10 11 12
Output 1
1
Explanation
Chip groups (1,3,5), (2,4,12), (6,8,9), (7,10,11) attain difference 1. Zero is impossible because outputs are distinct.
Input 2
2 2
3 1 3 3 3 3 3 3
Output 2
2
Explanation
One chip receives batteries of outputs 1 and 3, so its output is 1. Each of the other three chips receives two batteries of output 3. The machines have differences 2 and 0. A maximum below 2 is impossible because there is only one battery of output 1.