Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Nam currently has ~n~ separate electrical outlets. The number of plug slots on each of these outlets is ~a_1, a_2, a_3, \ldots, a_n~. There is a single fixed wall outlet providing power. To power any separate electrical outlet, it must be plugged into this wall outlet. We can also plug one separate outlet into another separate outlet that is already powered.
Nam has ~ m ~ electrical devices that need to be plugged in to be used. Help Nam determine the minimum number of separate outlets needed to power all ~ m ~ devices.
Input:
- The first line contains two integers ~ n ~ and ~ m ~ separated by a space, ensuring ~ 1 \leq n \leq 10^5 ~ and ~ m \leq 10^9 ~.
- The second line contains ~ n ~ integers ~ a_1, a_2, a_3, \ldots, a_n ~ separated by spaces, with ~ 1 \leq a_i \leq 10^9 ~.
Output:
- A single integer representing the minimum number of separate outlets needed. If using all separate outlets is still not enough, print ~-1~.
Sample Input
4 7
3 3 2 4
Sample Output
3
Bình luận