#abc235b. B - Climbing Takahashi
B - Climbing Takahashi
Score : points
问题描述
有 个平台排成一行。从左数第 个平台的高度为 。
高桥最初站在最左边的平台上。
由于他喜欢高度,他会尽可能重复以下操作:
- 如果他所在的平台不是最右边的平台,并且右侧相邻的平台高度大于当前平台,那么他将踏上下一个平台。
请找出他最终会站上的平台的高度。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are platforms arranged in a row. The height of the -th platform from the left is .
Takahashi is initially standing on the leftmost platform.
Since he likes heights, he will repeat the following move as long as possible.
- If the platform he is standing on is not the rightmost one, and the next platform to the right has a height greater than that of the current platform, step onto the next platform.
Find the height of the final platform he will stand on.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5
1 5 10 4 2
Sample Output 1
10
Takahashi is initially standing on the leftmost platform, whose height is . The next platform to the right has a height of and is higher than the current platform, so he steps onto it.
He is now standing on the -nd platform from the left, whose height is . The next platform to the right has a height of and is higher than the current platform, so he steps onto it.
He is now standing on the -rd platform from the left, whose height is . The next platform to the right has a height of and is lower than the current platform, so he stops moving.
Thus, the height of the final platform Takahashi will stand on is .
Sample Input 2
3
100 1000 100000
Sample Output 2
100000
Sample Input 3
4
27 1828 1828 9242
Sample Output 3
1828
update @ 2024/3/10 10:11:15