PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000085. Chim đậu trên dây (Birds on a Wire)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chim đậu trên dây (Birds on a Wire)
Birds on a Wire
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A wire has endpoints at and . Every bird must sit at least meters from either endpoint; every pair of birds must be at least meters apart. There are existing birds at valid integer positions ; none may be moved. Find the maximum number of additional birds that can be placed at integer coordinates.
Input
The first line contains . If , the next line contains integer positions .
Output
Print the maximum number of additional birds.
Subtasks
- Subtask 1 (20 points): ; ; ; ; existing positions are distinct and separated by at least .
- Subtask 2 (30 points): ; ; ; ; existing positions are distinct and separated by at least .
- Subtask 3 (50 points): ; ; ; ; existing positions are distinct and separated by at least .
Examples
Input
25 4 2
10 18
Output
2
Explanation
You can add birds at positions and , both at distance at least from the existing birds at and . No further legal position exists before the right margin , so the answer is .