CT27244

Sona's stamps Reckoning

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Sona found an old ledger of stamps in the tannery attic at the ferry landing of Crosswater. The margin notes pose a precise question. 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 <= 680; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 571 -508832 -711707 -199978 -266893 -824311 -820638 -951764 -62270 -182195 -244785 -745055 -609240 -264906 -866882 -540785 -470691 -564095 -269357 -410029 -899679 -57691 -586365 -324600 -294707 -83253 -987425 -582008 -961415 -830271 -615314 -831372 -741267 -337436 -376547 -34227 -360433 -813330 -408393 -819204 -844961 -540573 -478027 -408856 -489811 -608252 -471616 -975056 -69233 -961926 -996590 -209312 -605797 -423775 -51745 -393439 -525195 -540556 -80032 -503177 -708704 -335457 -3812 -308250 -29548 -567336 -866777 -246818 -562217 -275517 -518098 -519909 -647021 -553510 -276412 -693583 -188940 -352461 -396519 -343944 -861995 -512322 -847418 -134718 -893069 -878077 -180983 -194264 -916248 -21444 -975127 -791988 -769541 -698805 -339345 -365096 -347465 -669230 -571500 -107046 -227657 -823212…
Output: -2952

Example 2:

Input: 32 -126311 -701560 -850149 -374871 -668108 -210507 -117583 -257668 -150859 -231549 -697687 -539751 -112582 -950301 -521654 -633307 -123388 -795505 -664799 -156459 -446954 -44401 -170231 -221202 -872015 -243257 -778204 -305263 -548180 -103744 -580478 -785682
Output: -103744

Example 3:

Input: 92 -930346 -242968 -566899 -635086 -106913 -307881 -164957 -645814 -779767 -847317 -554479 -326110 -656848 -950835 -382113 -852403 -493377 -374030 -543554 -509252 -570750 -538280 -969144 -486550 -406761 -978340 -466199 -635439 -580558 -909346 -286289 -535888 -173877 -126715 -140875 -209467 -490892 -458899 -843561 -267283 -769600 -248002 -795449 -959560 -59254 -670957 -211530 -301966 -34333 -123686 -983402 -34934 -709200 -614341 -101178 -156379 -884865 -942867 -115488 -997864 -299011 -963691 -337412 -785004 -408898 -352782 -455759 -70443 -551417 -787399 -143394 -633261 -439665 -968197 -946714 -388658 -982818 -128486 -705914 -505487 -20505 -701566 -94018 -915147 -864799 -277690 -356433 -832803 -342496 -255068 -363940 -144555
Output: -34333

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sona's stamps Reckoning - EASY Coding Problem | CodeTikki