CT2290

The Runner-Up of Scrollkeep

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

The council of the archive halls of Scrollkeep pays by the answer, and Wheelwright intends to earn it. First: the full register of stamps. 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 <= 26; -100 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 23 960660 259891 378031 506884 455441 808473 942711 533389 322101 806274 949003 194152 7432 581217 695785 409924 535625 678843 574466 111258 383118 334828 85708
Output: 949003

Example 2:

Input: 4 255488 332489 577398 645376
Output: 577398

Example 3:

Input: 9 922700 642762 917380 278621 273598 924450 869921 708824 227408
Output: 922700

Constraints:

1 <= n <= 26; -100 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.
The Runner-Up of Scrollkeep - EASY Coding Problem | CodeTikki