CT23112

Leon's parcels Runner-Up

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The harbor bell rings at the northern keep of Frostgate; Leon weighs the day's parcels manifests and starts the calculations. 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 <= 632; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 543 -606619 -81954 -296867 -338716 -964618 -97062 -187697 -388644 -865168 -945756 -540343 -339567 -585299 -179975 -672909 -311657 -559560 -927671 -593892 -383245 -381544 -12443 -196308 -852265 -421413 -896687 -673507 -426838 -711941 -889716 -760572 -938587 -109140 -777835 -311792 -513142 -496882 -922730 -453400 -283478 -375710 -598527 -309288 -394760 -643360 -912475 -335554 -651154 -923661 -387011 -862692 -148723 -327466 -706615 -844 -71687 -288518 -682764 -142449 -101035 -534987 -343052 -784447 -427270 -173142 -789224 -576116 -382665 -12802 -694925 -720411 -984677 -412949 -257938 -464236 -68162 -42841 -134202 -587898 -240718 -765537 -191696 -227912 -559534 -937317 -296568 -678193 -136375 -908480 -189514 -701792 -816975 -19645 -394235 -662621 -285518 -568467 -193085 -369732 -395135 -152415…
Output: -1269

Example 2:

Input: 506 -907670 -724522 -860181 -652300 -726840 -372551 -710633 -766481 -716145 -552143 -919440 -543198 -974848 -761034 -955283 -234683 -955637 -91978 -900189 -122900 -634467 -788557 -241980 -697610 -472952 -376627 -197709 -701587 -775248 -67477 -851196 -83723 -252349 -968705 -218147 -793956 -157261 -894065 -746312 -40841 -634896 -104943 -834716 -323787 -216967 -644795 -302257 -402441 -628853 -915078 -17053 -951907 -568331 -546478 -506009 -761974 -736522 -951647 -413752 -68581 -390466 -996141 -826497 -870161 -564479 -923475 -906938 -23741 -63125 -495926 -546367 -983283 -781576 -984976 -671104 -580210 -257874 -812255 -616972 -801638 -679386 -356715 -590593 -102585 -645944 -982981 -492754 -432340 -801778 -118626 -655497 -514298 -327161 -545060 -905728 -567825 -974215 -152160 -47430 -709859 -1812…
Output: -8654

Example 3:

Input: 412 -202810 -520717 -820329 -589706 -218353 -938473 -352772 -895756 -416198 -361768 -480146 -602203 -562607 -966900 -602402 -494820 -983484 -385496 -684261 -847332 -344684 -600918 -359316 -175866 -895978 -475760 -97331 -763705 -713961 -128348 -999347 -853732 -282213 -528049 -872663 -310460 -774311 -5173 -192204 -369594 -690466 -644086 -109811 -172983 -562071 -149514 -270033 -573205 -174315 -263474 -64316 -976497 -624129 -370013 -897319 -319221 -969273 -334156 -341835 -544965 -568114 -199795 -8108 -246534 -469515 -233504 -986979 -152199 -368598 -100553 -344970 -261713 -689546 -659959 -491817 -470495 -370902 -834381 -767508 -994070 -174826 -139389 -736083 -439529 -290046 -154215 -769285 -600427 -128842 -52341 -37988 -207703 -516944 -126317 -971976 -89493 -161580 -235997 -660561 -454585 -2813…
Output: -3269

Constraints:

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

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