acmsguru |
---|
Закончено |
ARRIVE n c, meaning that a supplier has delivered n pieces of ice-cream priced c each to you, or
BUY n t, meaning that a student wants to buy n pieces of ice-cream, having a total of t money. The latter is processed as follows: in case n cheapest pieces of ice-cream you have cost no more than t (together), you sell those n cheapest pieces to the student; in case they cost more, she gets nothing. You start the day with no ice-cream.
HAPPYif she gets her ice-cream, and
UNHAPPYif she doesn't.
ARRIVE n cor
BUY n t, 1 ≤ n, c ≤ 106, 1 ≤ t ≤ 1012.
BUY-query output one line, containing either the word
HAPPYor the word
UNHAPPY(answers should be in the same order as the corresponding queries).
sample input | sample output |
ARRIVE 1 1 ARRIVE 10 200 BUY 5 900 BUY 5 900 BUY 5 1000 | HAPPY UNHAPPY HAPPY |
Название |
---|