CT1763

Emir and the Runner-Up

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

At the smokehouses of Brineport, Emir records each readings in a worn leather ledger. The guild wants answers, not guesses. 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 <= 65; -100 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 55 692014 712316 688262 375087 356574 184153 799266 9630 810398 235965 867261 930323 754396 291633 756635 575352 836188 306863 891697 231370 283237 149519 469308 390912 104555 722007 136673 680797 359638 877639 365994 322169 557299 181704 938565 980439 489605 377157 491277 409313 639121 279777 852223 241429 898389 617542 700524 677743 240840 115539 755817 888404 645572 666199 765490
Output: 938565

Example 2:

Input: 53 703768 577496 779585 850791 483908 955622 117788 809599 512813 65398 580472 917784 655641 635060 443571 636720 160118 647897 958637 628942 635106 87728 863555 208284 483833 490946 67783 817522 497441 410982 827560 149099 576728 751618 519685 800375 876445 328174 306499 688998 977150 809464 826004 786613 784397 359911 129560 468760 74057 77224 653833 680304 80556
Output: 958637

Example 3:

Input: 13 750946 143344 872042 408466 311890 254558 181110 211373 587651 891663 448931 581516 517253
Output: 872042

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Emir and the Runner-Up - EASY Coding Problem | CodeTikki