CT2337

Last readings of Ulrica

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Ulrica inherited the cooperage at the copper works of Verdigris along with its curious bookkeeping system for readings. Time to make sense of it. 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 <= 824; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 189 -927259 -418291 -521301 -471552 -291645 -877326 -980716 -386955 -72554 -70932 -503769 -23227 -74194 -604000 -16498 -692895 -578215 -933427 -656998 -800667 -183472 -468424 -709311 -534501 -267825 -472182 -320810 -9645 -538814 -348488 -66462 -402141 -201793 -261169 -467042 -28492 -67241 -306964 -88472 -84587 -901715 -497464 -809956 -28386 -737885 -924885 -760228 -139958 -975197 -123544 -67551 -255770 -673419 -635436 -587135 -778056 -400669 -327414 -921721 -513015 -876860 -506371 -156573 -822927 -380003 -804720 -958976 -316938 -594907 -400952 -168116 -245050 -240013 -51834 -64156 -494443 -458017 -69202 -487813 -187690 -814795 -97058 -411013 -169282 -924647 -601570 -951922 -11277 -811987 -321383 -521712 -177771 -129175 -905531 -340940 -947099 -254705 -437142 -248972 -371840 -347066 -627278 -289953 -939705 -484217 -339146 -949750 -648216 -218203 -761364 -250027 -303389 -554801 -495183 -287312 -836958 -716237 -434019 -931576 -68171 -200364 -817714 -625016 -571229 -139168 -989107 -653952 -169477 -828101 -667091 -387588 -993215 -268310 -441455 -767502 -173173 -779034 -881539 -58917 -331583 -365265 -140894 -360271 -541743 -692246 -831049 -131853 -940118 -461729 -371805 -689483 -6396 -742985 -66063 -121889 -407903 -140236 -410367 -678897 -481194 -909679 -708235 -770430 -147596 -765391 -101509 -970648 -850539 -466271 -340086 -851000 -878536 -892843 -9961 -61100 -100807 -494041 -550093 -323020 -568421 -259913 -469078 -48577 -550907 -821279 -702334 -229344 -633276 -716643
Output: -9645

Example 2:

Input: 107 -206941 -317858 -414517 -62925 -460206 -718480 -342653 -765745 -63677 -175915 -821528 -487916 -7779 -51535 -349540 -466801 -79518 -844948 -169469 -243068 -591615 -870275 -979749 -783277 -308802 -235718 -688831 -12689 -346012 -215961 -598092 -763303 -192802 -757627 -466207 -596707 -573022 -143985 -325836 -22998 -147641 -804617 -817007 -699862 -166037 -247703 -776605 -621934 -345321 -587880 -876993 -629727 -162430 -787818 -957756 -752187 -519796 -150648 -13504 -970220 -343972 -194108 -512209 -618609 -532234 -433990 -981474 -322530 -301578 -93731 -170817 -871579 -476794 -35011 -488552 -954040 -952504 -186074 -547088 -808356 -380648 -343465 -713190 -51286 -546718 -978607 -330248 -825749 -930635 -758994 -358375 -387221 -262025 -943775 -314546 -219698 -572124 -362992 -811965 -650730 -698601 -54908 -238495 -595009 -228270 -272233 -568000
Output: -12689

Example 3:

Input: 6 -356560 -472457 -305702 -908154 -183212 -523037
Output: -305702

Constraints:

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

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