Do You Have Enough Money?
Problem Description:
Riad is a
student of BUBT. His hobby is shopping. When he goes for shopping he wants to
buy whatever he sees. He always forgets how much money is in his hand. To
overcome this problem he has decided to write a program that will read the
amount of money he has and the prices of the items he wants to buy. Determine
whether he has enough money to buy everything he selected or whether he is in short
of money. If he does not have enough money, the program will indicate the
amount of the shortfall. In case of
short of money the program also indicates the list of items he may buy with his
money.
Input:
The first line contains a single integer N, which will denote the amount of money he has in his hand. The
second line contains M(1<=M<=10) that indicates the number
of items Riad is interested to buy. The third line contains price of each
element that Riad is interested to buy.
Output:
In output there will be two lines. The first line shows whether Riad has
enough money or not (print BUY ALL ITEM
or SHORTFALL depending on the money in his hand). In case of shortfall
print the amount of shortfall. The second line contains the list of items that Riad
may buy in case of shortfall.
Sample Input/Output:
Sample Input
|
Sample Output
|
100
4
25 60
75 70
1000
5
25
60 100 85 50
|
SHORTFALL Tk: 130
YOU MAY BUY
75
25
BUY ALL ITEMS
|
No comments:
Post a Comment