13465 - max/min in assigned area
|
Time |
Memory |
Case 1 |
1 sec |
32 MB |
Case 2 |
1 sec |
32 MB |
Case 3 |
1 sec |
32 MB |
Case 4 |
1 sec |
32 MB |
Case 5 |
1 sec |
32 MB |
Case 6 |
1 sec |
32 MB |
Case 7 |
1 sec |
32 MB |
Case 8 |
1 sec |
32 MB |
Case 9 |
1 sec |
32 MB |
Case 10 |
1 sec |
32 MB |
Description
Given a list of numbers, an some indicators,
you need to find out the maximum or minimum number in the list according to the indicators.
Input
There is only one line in the input, which contains the list of numbers and some indicators.
An example is shown below.
9,0,21,i1,61,66,f5,91,62,22,22
Note that
- The red element in the line is an indicator where you can find it start with the character "i" and followed by a digit. (1 in this example). When you meet "i1", you need to find the maximum; and "i2" to find the minimum.
- The green element in the line is also an indicator. It starts from either "f" or "b" and followed by a number k. ("f5" in this example). The character "f" stands for "front". It means you need to find the answer from the first k numbers. The character "b" stands for "back". It means you need to find the answer from the last k numbers. In this case, "f5" means you need to find the answer from the first 5 numbers. When there is no this kind of indicator, you need to find the answer from all the numbers. ( Please note that there would be only one indicator like this. )
- The remaining blue elements are the numbers of the list of numbers.
- You need to consider some edge cases, such as
4.1. If the blue elements are the same number, the input can sometimes only give i1 or i2 without b or f info. This is considered valid input.
4.2. If the number behind b or f is 0, such as b0, it is considered an empty range. The input is considered non-valid input.
4.3 If the input without i indicator. The input is consider non-valid input
- If the input is not valid, print "None" instead.
Output
The output is a line of text with the maximum/minimum number from the list.
Tags