#K88822. Taco Hike Analysis

    ID: 37394 Type: Default 1000ms 256MiB

Taco Hike Analysis

Taco Hike Analysis

During a hike, a series of altitude measurements is recorded. Your task is to analyze the log and determine whether the hike contains more uphill climbs or downhill descents.

An uphill climb is defined as a maximal contiguous subsequence where each successive altitude is strictly higher than the previous one. Similarly, a downhill descent is defined as a maximal contiguous subsequence where each successive altitude is strictly lower than the previous one.

Formally, if the list of altitudes is \(a_1, a_2, \dots, a_n\), an uphill climb is a segment \(a_i, a_{i+1}, \dots, a_j\) such that \(a_i < a_{i+1} < \cdots < a_j\) and it is maximal. A downhill descent is defined analogously.

Your program should output:

  • UPHILL if the number of uphill climbs is greater than the number of downhill descents.
  • DOWNHILL if the number of downhill descents is greater than the number of uphill climbs.
  • EVEN if both counts are equal.
  • inputFormat

    The first line of input contains a single integer \(T\) denoting the number of test cases.

    For each test case, the first line contains an integer \(n\) representing the number of altitude measurements. The following line contains \(n\) space-separated integers representing the altitude log.

    outputFormat

    For each test case, output one line containing one of the strings: UPHILL, DOWNHILL, or EVEN, according to the analysis of the hike log.

    ## sample
    3
    6
    1 3 2 4 6 5
    5
    3 2 1 4 5
    4
    2 2 2 2
    
    EVEN
    

    UPHILL EVEN

    </p>