Due to overwhelming demand, the principal has installed one of those "take a number" dispensers to help the attendance secretary manage the line for late slips. The dispenser is filled with slips of paper numbered in order from
You will be given detailed data for a number of days in the late slip lineup. The first line contains an integer TAKE
, it means a student has arrived and taken the next number (when a student takes the last number available, the machine is immediately refilled). If a line contains the word SERVE
it means that the attendance secretary has served the next student in line (this word will only appear in the file when there is at least one student waiting). If a line contains the word CLOSE
it means that the desk has closed for the day and the attendance secretary will serve the students remaining in line and then go home. The very last line will contain the string EOF
. At no time will there be more than
Your job is to keep track of the line. Each time you encounter the word CLOSE
, you must print three integers on a single line, each separated by a single space. The first integer represents the number of students who were late that day, the second integer represents the number of students who remained in line after the desk was closed, and the third integer represents the next number in the take a number machine for the next day.
Sample Input
23
TAKE
TAKE
SERVE
TAKE
SERVE
SERVE
CLOSE
TAKE
TAKE
TAKE
SERVE
CLOSE
TAKE
SERVE
TAKE
SERVE
TAKE
TAKE
TAKE
TAKE
TAKE
TAKE
SERVE
CLOSE
EOF
Sample Output
3 0 26
3 2 29
8 5 37
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments
don't even understand this question . very wordy and no idea what it actually wants me to do
Is there some place to view the actual test data?
My code works with the sample data. It works with case 1 and case 3 of the test data, but generates a WA for case 2, with no indication of what the failure was. How am I supposed to fix something when I don't know what the unacceptable output is?
Im getting test case 1 and 2 right but for the last one it says 1 0 0?
You probably solved this by now, but I was getting similar and mine was caused by the way that I was looping the ticket numbers once they got to 999.
Since the original data were weak, an additional test case was added, and all submissions were rejudged.