CT1297

The Moonlit Runner-Up

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Hestia runs the kitchen at the trading post of Goldmeadow. Today the books show a list of stamps, and the numbers must be worked out before sundown. 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 <= 88; -1000000 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 84 -30962 194570 66909 90545 -481199 -430959 654938 -598753 -761238 -370750 -503036 -146396 287921 -990373 167320 682379 794425 923483 37702 147377 255452 445034 -110452 -685792 -336579 52872 71418 -440171 -435203 -630432 -96987 -383303 391931 -587258 141698 795825 309264 -680721 443913 -402841 -220231 511873 450697 -116281 -153625 44161 -316482 -756473 525538 -403405 876554 476278 761031 -669413 -988259 959227 -807490 202876 204435 -960794 458104 -762274 868848 86931 677633 -915017 -660262 298224 -224405 -640913 298817 50467 704156 613206 -483852 -907990 -89142 388148 -736341 -201883 -672010 -885791 46670 594316
Output: 923483

Example 2:

Input: 14 752300 -958886 116188 513909 306432 982959 -349567 -723963 -455020 -625410 390490 -63805 -783918 299823
Output: 752300

Example 3:

Input: 45 481617 447298 -570028 -351480 577819 621370 543366 -335969 307941 -456351 25413 798963 -420611 242658 774869 265978 854985 71069 560114 985338 -574234 -542299 576777 -757161 -242616 -653279 -636687 273006 196195 252430 872956 -28837 -869022 -169864 -427160 -877240 -734648 329020 307329 873274 -211694 -434396 -602724 90705 -884586
Output: 873274

Constraints:

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

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