CT989

Cora's Lazy ingots

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Morning light hits the jade shrine of Serpentis as Cora unrolls the day's manifest of ingots. The tally will decide the next shipment. 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 <= 36; 0 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

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

Example 2:

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

Example 3:

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

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Cora's Lazy ingots - EASY Coding Problem | CodeTikki