Determine the maximum possible height of a tower built from a sequence of blocks under simple stacking rules.
Giga Tower
You are given a sequence of blocks with different heights. Build a tower by taking blocks in order and applying the rule that each next chosen block must satisfy the tower condition from the previous one.
Your task is to compute the best achievable tower height according to the problem's stacking rule.
This is an implementation-style problem where the key is to process the blocks carefully and track the current best tower state as you scan through the input.
Input Format
- The first line contains an integer — the number of blocks.
- The second line contains integers describing the block values/heights.
Output Format
- Print a single integer: the maximum tower value/height that can be obtained.
Constraints
- Block values fit in standard 32-bit signed integers
- Use an or approach
Example 1
Input
5 1 2 3 2 5
Output
5
Explanation
A valid tower can be formed by choosing blocks so that the tracked tower value reaches 5.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.