CT1372

Kael's Frosted coins

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

The scribe Kael has been asked to approve the repair estimates. On the desk lies a long table of coins readings. Task: Read n integers and print the second distinct largest value. If every value is the same, print -1. Input format: First line: n. Second line: n space-separated integers. Output format: Print the second distinct maximum, or -1 if none. Constraints: 1 <= n <= 38; 0 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 35 5 4 9 2 7 7 8 3 5 2 5 5 8 1 5 2 4 0 2 9 10 4 2 8 0 0 6 1 10 5 0 2 0 7 1
Output: 9

Example 2:

Input: 22 6 5 6 0 0 4 7 1 10 7 9 4 6 2 8 10 6 0 6 4 0 0
Output: 9

Example 3:

Input: 6 4 5 8 8 1 4
Output: 5

Constraints:

1 <= n <= 38; 0 <= a[i] <= 10; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.