CT22569

Quade's Ruby Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

At the rook towers of Chessfield, Quade records each barrels 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 <= 915; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 596 -701992 -922014 -560002 -306151 -9110 -127754 -27104 -229248 -284380 -827835 -736066 -830469 -609588 -903729 -922807 -695789 -292986 -609227 -141652 -334210 -757993 -77681 -133679 -854336 -236010 -581997 -819796 -869298 -546837 -540421 -176447 -214746 -626286 -987299 -881694 -242836 -24874 -785184 -496458 -142683 -53020 -763770 -394796 -978118 -825558 -362873 -5555 -419328 -509270 -34420 -535049 -634068 -71737 -289167 -418725 -439820 -842955 -525860 -514524 -456765 -645252 -8929 -418122 -773580 -464961 -509953 -921393 -689209 -776189 -732606 -688718 -626556 -993303 -112769 -402210 -441341 -576914 -663697 -563366 -901697 -53069 -790894 -63569 -560893 -229875 -299172 -679366 -177404 -767520 -120790 -676349 -283195 -467404 -293209 -407269 -246424 -914309 -348827 -684886 -640169 -563023 -5…
Output: -4167

Example 2:

Input: 369 -675202 -764205 -451055 -410624 -614058 -970073 -642686 -315519 -592566 -117298 -124143 -120778 -395554 -384917 -54670 -432469 -788364 -283068 -770879 -814043 -35712 -550586 -894067 -841086 -824731 -596323 -720807 -647787 -369553 -325081 -366793 -678185 -759287 -602349 -919003 -837409 -221969 -863631 -760043 -169567 -201614 -984585 -215822 -742850 -314326 -708617 -852642 -109546 -150538 -412667 -263331 -198992 -891987 -69809 -670539 -837759 -767496 -996078 -853117 -120251 -653604 -581873 -718826 -189593 -421963 -932437 -436262 -39436 -228611 -140806 -470234 -714887 -59655 -292580 -886357 -379605 -570905 -340531 -519484 -146460 -500922 -505692 -511028 -646667 -744826 -23203 -662220 -931709 -960575 -202671 -148511 -853260 -750698 -419857 -181501 -121829 -893185 -496161 -502087 -741425 -5…
Output: -10699

Example 3:

Input: 166 -508280 -366771 -649394 -1937 -217009 -821762 -244867 -312794 -10944 -818714 -644668 -492411 -469628 -479553 -931289 -786162 -584530 -214512 -909236 -474474 -646406 -467852 -156909 -269662 -982675 -351513 -812510 -505583 -519510 -814074 -536516 -221639 -374178 -244794 -836403 -147163 -180053 -341081 -697096 -476306 -307270 -347358 -342602 -685321 -465971 -689026 -372610 -205066 -583269 -893602 -624455 -906043 -561524 -573185 -455078 -986921 -587531 -271775 -200187 -174865 -837832 -105740 -261539 -907582 -363642 -364487 -869231 -199034 -966496 -656986 -665010 -668433 -222951 -416954 -277373 -777493 -462433 -820950 -16403 -842044 -401113 -425988 -177811 -59561 -90989 -900358 -672632 -960473 -620575 -554117 -585423 -792558 -936996 -559564 -457204 -769278 -81108 -142283 -377105 -694171 -45…
Output: -3768

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.