PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000126. Ổ cắm điện (Sockets)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ổ cắm điện (Sockets)
Sockets
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You have powered wall sockets, devices and power strips. Strip has sockets and consumes one socket to plug in. Strips may be chained. Find the minimum number of strips needed to power all devices, or -1 if impossible.
Input
The first line has . The next line contains integers .
Output
Print the minimum number of strips, or -1.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3 5 3
3 1 2
Output
1
Explanation
Initially there are three sockets. Plugging in a strip with three outlets creates usable sockets, so one strip suffices; zero strips cannot power five devices.