#QHD0000032. Cắt ruy băng (Cut Ribbon)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cắt ruy băng (Cut Ribbon)
Cut Ribbon
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You have a ribbon of length . Cut it completely into smaller pieces, each of which must have length exactly one of , , or .
A length may be used repeatedly, and you need not use all three lengths. The lengths of the pieces must sum to exactly , with no leftover ribbon. At least one valid cutting is guaranteed.
Find the maximum possible number of pieces.
Input
One line contains , , , and : the ribbon length and the three allowed segment lengths.
Output
Print the maximum number of ribbon segments.
Subtasks
- Subtask 1 (20 points): ; ; ; ; At least one valid cutting is guaranteed.
- Subtask 2 (30 points): ; ; ; ; At least one valid cutting is guaranteed.
- Subtask 3 (50 points): ; ; ; ; At least one valid cutting is guaranteed.
Examples
Input
5 5 3 2
Output
2
Explanation
Cut the ribbon of length into segments of lengths and . Three segments are impossible because each would have length at least , requiring total length at least . The answer is .