#K40967. Find the Steepest Uphill Path

    ID: 26760 Type: Default 1000ms 256MiB

Find the Steepest Uphill Path

Find the Steepest Uphill Path

You are given a mountain trail represented as a sequence of elevations. Your task is to determine the steepest uphill path in the trail. Specifically, you need to find two indices i and j (with i < j) such that the difference \( \text{elevations}[j] - \text{elevations}[i] \) is maximized. If no uphill path exists (i.e. the trail is non-increasing), then output 0 with indices 0 and 0.

If multiple paths yield the same maximum difference, choose the one with the smallest starting index i. The answer should be given as three integers: the maximum elevation gain, the starting index, and the ending index.

Note: The indices are 0-based. The maximum difference is defined as \( \max_{0 \le i < j < n} (\text{elevations}[j] - \text{elevations}[i]) \). If there is no increase along the path, the result is \( (0, 0, 0) \).

inputFormat

The first line of input contains a single integer \( n \) (the number of points in the trail). The second line contains \( n \) space-separated integers representing the elevations along the trail.

outputFormat

Output three space-separated integers: the maximum elevation gain, the starting index, and the ending index of the steepest uphill path.

## sample
1
5
0 0 0