E. 练50.2 卡牌游戏 II

    Type: Default 1000ms 64MiB

练50.2 卡牌游戏 II

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

Xiaoming is playing a card game. He has nn cards, each with a positive integer aia_i written on it, representing the damage value of the card. When played, the card reduces the enemy's health by aia_i. The enemy's health is bb, and Xiaoming wins when the enemy's health becomes less than or equal to 00.
Xiaoming must use the cards in order to deal damage to the enemy. He wants to know how many cards he needs to use to win. If he cannot win even after using all cards, output 1-1.

Input Format

The first line contains two positive integers nn and bb (1n1051≤n≤10^5, 1b10181≤b≤10^{18}), representing the number of cards and the enemy's health.
The second line contains nn positive integers aia_i (1ai1091≤a_i≤10^9), representing the damage value of each card. Xiaoming will use the cards in the order they are read.

Output Format

Output a single line containing an integer, representing the number of cards Xiaoming needs to use. If he cannot defeat the enemy even after using all cards, output 1-1.

Sample

3 5
2 3 4
2

20251129 B班作业(8)

Not Claimed
Status
Done
Problem
6
Open Since
2025-11-29 0:00
Deadline
2025-12-7 23:59
Extension
24 hour(s)