DMOPC '14 Contest 7 P2 - Tides

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Tusk has been stranded on an island for some time now, and it's fair to say that he's grown terribly bored. As such, he's started to find ordinary things immensely fascinating.

Today, he's interested in the waves he sees. He notes that at certain times of the day, the water level either increases or decreases. Realizing this phenomenon is due to tides, he is now most fervent about determining the difference in water level between high tide and low tide.

To this end, he's measured the water level N times throughout the day using a high-precision measuring device such that each reading is a unique integer in the range 1 \dots 10\,000 inclusive.

He knows that after measuring the absolute minimum reading at low tide, the transition to the absolute maximum reading representing the water level at high tide consists of a strictly increasing sequence of water level readings. He's interested in the difference between the absolute maximum and absolute minimum readings: the water level difference between tides.

It's possible that he made a mistake in writing down these readings, however, in which case the sequence between the low tide reading and high tide reading will not be strictly increasing. If this is the case, it's likely that the data is useless — the water level difference cannot be accurately determined — and should be scrapped.

Input Specification

The first line will contain the single integer N (3 \le N \le 1\,000).

The second line will contain N space-separated positive integers: the water level readings in chronological order.

Output Specification

The integer difference in water level between high tide and low tide. If the difference cannot be accurately determined, output unknown.

Sample Input 1

5
2 1 3 5 10

Sample Output 1

9

Sample Input 2

5
1 2 5 4 9

Sample Output 2

unknown

Comments


  • 0
    petlop222  commented on July 17, 2024, 10:30 p.m.

    I only AC the first two test cases, anybody know why? I cant find the problem :[


  • -7
    dmitri_p86  commented on June 5, 2024, 5:27 p.m. edited

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 3
      b_nary  commented on June 6, 2024, 2:49 a.m.

      python isn't the only language y'know


    • 4
      BalintR  commented on June 5, 2024, 11:59 p.m.

      It is much more convenient in many languages to have the number of inputs specified. You will find that almost all problems specify the number of tokens for this reason.