CT932

Emir's Runner-Up Ledger

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Caravans arrive at the jade shrine of Serpentis with crates of parcels, and Emir the reckoner 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 <= 86; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 50 810 227 327 640 617 165 978 130 357 891 269 64 185 450 543 364 138 11 55 303 594 484 654 736 84 574 293 953 444 945 443 107 276 494 276 117 758 844 163 561 486 557 596 594 597 574 859 442 412 255
Output: 953

Example 2:

Input: 13 770 530 731 479 80 509 838 662 622 262 492 76 543
Output: 770

Example 3:

Input: 18 574 658 467 708 734 52 491 539 523 775 706 711 805 518 968 769 410 74
Output: 805

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Emir's Runner-Up Ledger - EASY Coding Problem | CodeTikki