PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000118. Ném kiếm tiêu diệt quái vật (Katana Thrower)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ném kiếm tiêu diệt quái vật (Katana Thrower)
Katana Thrower
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A monster has health. Sword can be swung any number of times for damage per swing, or thrown once for damage, after which it is lost. Find the minimum number of attacks to deal at least damage.
Input
The first line contains . Each of the following lines contains .
Output
Print the minimum number of attacks.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
2 17
3 5
4 8
Output
3
Explanation
Swing the second sword once (4 damage), then throw it (8 damage), and throw the first sword (5 damage), dealing damage in three attacks.