#C909. High Number Detector
High Number Detector
High Number Detector
You are required to implement a program that processes a sequence of operations on numbers. The program supports three types of operations:
- add X: Add the number X to the sequence. X can be an integer or a floating-point number.
- get_highest: Print the highest number in the sequence. If no numbers have been added yet, output "No numbers in sequence yet".
- get_sequence: Print all the numbers in the sequence in the order they were added. The numbers should be printed on one line separated by a single space.
The input starts with an integer Q representing the number of operations. The following Q lines each contain one operation. Process the operations in order and output each result (if any) on a separate line.
Note: When printing numbers, if a number is an integer (i.e. its fractional part is zero) print it without a decimal point.
Mathematical note: Let \( a_1, a_2, \dots, a_n \) be the numbers added. Then, for each call to get_highest, output \( \max_{1 \le i \le n} a_i \) if at least one number has been added; otherwise output an error message.
inputFormat
The input is read from standard input and has the following format:
Q operation_1 operation_2 ... operation_Q
Here, Q (1 ≤ Q ≤ 105) is the number of operations. Each operation is one of the following:
add X
— add a number X (which can be integer or floating-point) to the sequence.get_highest
— print the highest number in the sequence. If no number has been added, output "No numbers in sequence yet".get_sequence
— print the entire sequence of numbers, space separated, in the order they were added.
outputFormat
Output the result for each get_highest
and get_sequence
operation on a new line. For get_highest
, output the maximum number (formatted without a decimal point if its fractional part is zero) or the error message "No numbers in sequence yet" if the sequence is empty. For get_sequence
, output the sequence as space-separated numbers in the order they were added.
6
add 3
get_highest
add 5
get_highest
add 2
get_sequence
3
5
3 5 2
</p>