CT2154

Cleo's stamps Reckoning

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Caravans arrive at the rook towers of Chessfield with crates of stamps, and Cleo the surveyor must account for every last one. 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 <= 42; -100 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 31 -51 -89 -87 -14 -42 -1 3 -3 -20 -100 -62 -46 -46 -88 -44 -3 -50 -93 -62 -11 -32 -59 -21 -23 -9 -84 -57 -26 -36 -78 -5
Output: -1

Example 2:

Input: 16 -16 -60 -50 -12 -25 -35 -90 -87 -18 -94 -36 -81 -59 -68 -31 -46
Output: -16

Example 3:

Input: 29 -62 -59 -14 -35 -17 -81 -82 -47 -78 -76 -59 -48 -18 -10 -62 -69 -3 -36 -16 -9 -90 -35 -4 -54 -66 -93 -27 -82 -53
Output: -4

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Cleo's stamps Reckoning - EASY Coding Problem | CodeTikki