Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
At WonderLand Theme Park, there is a long row of N magic stalls (2 ≤ N ≤ 248), each with a power level between 1 and 40. A magic stall can be upgraded using the following rule: Upgrade Move: If two adjacent stalls both have the same power, you may merge them into one stall with power (power + 1). Example: Two stalls with power 7 side-by-side can merge into a single stall with power 8. After merging, the number of stalls decreases by 1. Goal: Your goal is to maximize the highest stall power in the entire row after performing as many merges as you want. You may merge in any order. Input Format: • First line: N , the number of stalls • Next N lines: the initial power of each stall Output Format: Print one integer: The maximum stall power you can obtain by merging wisely. Sample Input: 4 1 1 1 2 Sample Output: 3 Question Input File: • Input: https://shorturl.at/HrFU0