CT22834

Cressida's Polished Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The council of the river town of Willowford pays by the answer, and Cressida intends to earn it. First: the full register of ingots. 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 <= 359; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 292 -141610 -460481 -247083 -734905 -117095 -404518 -77978 -189322 -613218 -775788 -948851 -953641 -93544 -934608 -54033 -970178 -600539 -65902 -144140 -624144 -399433 -636137 -110206 -929014 -537435 -324170 -168111 -18841 -933789 -62145 -794398 -441930 -555251 -319469 -365329 -797907 -74642 -414349 -319384 -410744 -125674 -352130 -218578 -911441 -727619 -814110 -100594 -834890 -633472 -707462 -542182 -638062 -92130 -418839 -5111 -390611 -43125 -905810 -355659 -763345 -115672 -179159 -734812 -995119 -796593 -144820 -963349 -660034 -913295 -478880 -370022 -919993 -140231 -408030 -858171 -987247 -574440 -408296 -133454 -962612 -666362 -271658 -933746 -893094 -102037 -438492 -554371 -154628 -36413 -697738 -200378 -247484 -502526 -511419 -751991 -263603 -308467 -121998 -543794 -417487 -926352 …
Output: -5111

Example 2:

Input: 122 -896195 -679287 -168401 -958442 -310339 -700224 -846125 -431747 -319810 -920772 -183127 -240015 -171343 -106267 -430704 -232212 -672855 -811303 -250950 -388884 -205472 -551027 -610330 -486047 -847251 -13665 -651122 -394628 -946650 -329897 -40229 -158339 -361699 -616694 -323611 -471836 -434841 -547579 -65605 -633664 -150142 -114588 -798030 -519511 -814053 -437606 -244311 -418107 -571079 -900191 -317268 -424349 -779418 -614013 -170472 -133585 -233777 -451749 -13029 -662172 -361609 -580378 -378618 -809235 -941161 -494992 -854855 -286746 -185216 -421213 -208373 -183784 -449952 -48738 -835273 -68318 -955476 -623549 -181817 -120257 -304550 -821278 -212928 -728685 -325179 -820087 -999118 -986390 -973713 -148517 -960475 -694319 -617316 -792426 -425357 -287420 -316851 -728778 -411634 -894896 -2…
Output: -13665

Example 3:

Input: 347 -9388 -266309 -861137 -55260 -971996 -460568 -524266 -340668 -644087 -73777 -304394 -33002 -503499 -580773 -402212 -656112 -667096 -20887 -479909 -989351 -688937 -709000 -989207 -476547 -787481 -95952 -839055 -75855 -354489 -445898 -163758 -874276 -863737 -526646 -444612 -416444 -558271 -133025 -814218 -346811 -628360 -232704 -167490 -333598 -540742 -46552 -830849 -163010 -221740 -444266 -934926 -508661 -934907 -495459 -805753 -467713 -539492 -28954 -700264 -308823 -284257 -710645 -770009 -161 -616937 -948486 -593725 -923901 -823332 -489288 -752319 -277033 -449321 -895480 -622249 -958766 -266334 -972149 -858221 -500605 -948800 -314010 -511285 -235803 -845299 -918711 -806070 -127940 -107790 -202219 -609499 -504557 -785059 -84981 -592279 -108947 -159717 -127327 -872222 -332156 -371167 -3…
Output: -9388

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Cressida's Polished Ledger - EASY Coding Problem | CodeTikki