CT24669

Uma and the Runner-Up

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

At the terraced vines of Grapehollow, Uma records each stamps 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 <= 697; 0 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 67 697931042 62489480 314129481 607146702 32262492 714561036 146483993 326494335 480935577 89225046 216896840 12846769 540941228 35235920 933214098 970328325 464940107 320849846 583616164 697865190 201111838 940653888 586026987 870911202 110238888 128170915 656887776 142335841 956603762 452597442 905563871 291808797 931344639 325654602 963247832 170582715 146997867 480215309 62594491 803930722 502586371 464119730 711530065 540966124 815115482 796302153 828406894 988364895 821689670 756650974 310460752 29920316 822506079 15799663 819360547 805641382 70411060 431758284 622969173 683691498 834698926 763098415 201956678 687469531 425022812 458137736 964939605
Output: 970328325

Example 2:

Input: 209 42912447 467309392 793448350 799241936 127461037 380249098 388059217 362466114 41641542 770510270 623588663 644197734 54960286 903232194 176205275 329777365 933112616 384106936 633986970 199066763 6282351 801565674 902032730 633661133 750156720 172390369 972512618 386184659 160470291 21830167 599553354 119203230 13358899 767531122 163797516 128710647 385975297 34509909 656579798 961347451 908516131 602480939 394918889 186813125 203702161 991303523 853077269 16213329 268657846 550989056 431729787 919147699 979972745 441145412 256979596 735011550 762353007 246159362 204020761 221513804 645565790 143182584 900916063 385613847 504305545 206629016 931555857 807105881 816040290 946894892 6532208 353353377 810983081 199083449 445687449 964277264 977948381 696830454 851198133 276449824 9860200…
Output: 991303523

Example 3:

Input: 327 977447246 3049587 705479177 107823993 578736526 128909365 781390634 180050901 380507311 189854446 776015514 741462196 991503987 937472737 731807942 328258997 998259803 458223359 848460742 477368643 20107920 490391479 22744871 511025033 774233536 812302740 614300029 639272865 556636156 680985217 32881999 542512360 142067119 432624291 3740503 769369684 292575340 963639451 782880437 717404298 138167615 718018075 530668520 583495316 958971766 637550301 108386270 633985454 700213505 822978800 129946921 104065500 738786391 164563626 562842905 476321135 682479753 13301712 703821811 839906949 48778274 730531205 159458529 839741374 848145634 581891020 432790757 470605864 999502680 536234140 915090931 360375969 103225939 783256988 291029079 932430741 665427468 915542761 442844757 147399049 22844…
Output: 999502680

Constraints:

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

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