Check the Check
InterviewTime limit2sMemory limit512 MB
Read dish names and price-quantity pairs until the line TOTAL, then print PAY if the waiter's total is at most the sum of price times quantity, else PROTEST.
- Level
Easy2 of 10
- Topics
- Implementation, String, Math
- Solved
- No attempts yet
Problem

As a tourist in Paris, you are told to always check the itemized bill (also called the check) that arrives at the end of a meal, the one listing what you ordered and the total price. Such bills are often handwritten, and the waiter adds the total up by hand. You do not want to pay more than your meal costs, so you protest whenever a mistake favors the restaurant. If the restaurant charges you less than it should, you pay without a word.
Write a program that decides whether to pay the total printed on the check or to protest about it.
Input
The input consists of lines.
- For every with , line holds the name of an ordered dish.
- For every with , line holds the integer price of in euros and the number of orders of , separated by one space.
- Line holds the word TOTAL.
- Line holds the integer total in euros computed by the waiter.
The value of is not given in the input. Read dish entries until you reach the line equal to TOTAL.
Limits
- For every with :
- has at most 1000 characters, and is never equal to TOTAL;
- ;
- ;
- ;
- .
Output
Print one line. Print PAY if the total on the check is less than or equal to the real total , and PROTEST if it is larger.