#CCBOTPBA0000005. Tiền dư sau mua hàng (Money Left After Shopping)
Tiền dư sau mua hàng (Money Left After Shopping)
Money Left After Shopping
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
You have m units of money and must buy all n items costing a_i each. If you can afford them print YES and the balance, otherwise NO and the additional amount required.
Input
First n m, followed by n item prices a_i.
Output
Print YES d with nonnegative remaining balance, otherwise NO d with nonnegative shortage.
Subtasks
-
Subtask 1 (20%):
n ≤ 10, prices/budget0..100. -
Subtask 2 (30%):
n ≤ 1000, prices/budget0..10^6. -
Subtask 3 (50%):
n ≤ 100000, prices/budget0..10^9.
Examples
Example 1
Input:
3 20
5 8 9
Output:
NO 2
Explanation: Total price is 22; the shortage is 2.
Example 2
Input:
2 10
4 6
Output:
YES 0
Explanation: The budget exactly matches the price.
Example 3
Input:
0 0
Output:
YES 0
Explanation: Buying zero items with zero budget is sufficient.