#K8666. Next Customer Ticket
Next Customer Ticket
Next Customer Ticket
You are given a list of integers representing ticket numbers in a queue. A ticket number of -1
indicates that the ticket was cancelled. Your task is to output the first ticket number that is not cancelled. If all tickets are cancelled, output \(-1\).
For example, if the input is:
1 2 -1 4 5
Then the output should be:
1
Note that the input will be provided as a single line from standard input and the output should be printed to standard output.
inputFormat
The input consists of a single line of space-separated integers, where each integer represents a ticket number. A ticket number of -1
means that the corresponding ticket has been cancelled.
For example:
1 2 -1 4 5
outputFormat
Output a single integer: the ticket number that will be served next (the first ticket that is not -1
). If all tickets are cancelled, output \(-1\).
1 2 -1 4 5
1