CT40053

The Mossy ledgers of Petra

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The paymaster Petra has been asked to rank apprentices for the new term. On the desk lies a long table of ledgers readings. Task: For each element print the value of the nearest element to its right that is strictly greater, or -1. Input format: First line: n. Second line: n integers. Output format: Print n answers space-separated. Constraints: 1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 3922 849465933 426659370 746401477 -942372871 -844463924 -895928167 404654040 332204451 -788452430 -582184176 -720078640 540839072 972288064 364932991 575871435 196362614 769573809 -707759780 -182051621 -456896 982101906 -884363907 -160433615 -572526018 -789367241 -883138144 648279667 356478995 599879379 773419851 -870265601 -592882743 -222276401 137682590 -218538543 557023431 -864663224 -97905250 466338096 432160394 618316191 959959303 847317396 460291529 -428472977 343789715 886559484 -317966228 317994088 -408740245 -487621412 486538749 -195971755 802317986 732122554 -311441840 -737331683 -301824909 -823593156 -892115769 -782454779 -232559448 896988669 225564005 598125967 -593094895 -479699495 159531634 -717064052 -996216983 568265760 -122875151 610965024 420154725 535963 920624969 40938…
Output: 972288064 746401477 972288064 -844463924 404654040 404654040 540839072 540839072 -582184176 540839072 540839072 972288064 982101906 575871435 769573809 769573809 982101906 -182051621 -456896 982101906 987072168 -160433615 648279667 648279667 648279667 648279667 773419851 599879379 773419851 959959303 -592882743 -222276401 137682590 557023431 557023431 618316191 -97905250 466338096 618316191 618316191 959959303 987072168 886559484 886559484 343789715 886559484 896988669 317994088 486538749 486538749 486538749 802317986 802317986 896988669 896988669 -301824909 -301824909 -232559448 -782454779 -782454779 -232559448 896988669 920624969 598125967 610965024 -479699495 159531634 568265760 568265760 568265760 610965024 610965024 920624969 920624969 920624969 987072168 662525923 662525923 714844758…

Example 2:

Input: 2040 579113445 -476622627 -772218234 981383437 31840953 -654029704 161929563 -193543216 61223631 683935777 -346319033 -941565908 -391400153 -751918676 -505825209 981977002 726617971 225678793 951202852 108404814 -485626483 10033932 534941380 650697785 103952097 -582897293 732495986 719039749 585497159 884823089 -398243294 -350656504 -54478278 814656580 -781279687 139145465 -986956966 -126430324 94284330 -611909572 627119368 -118297955 219980051 776414896 10353307 972442117 438748866 -804398833 151020403 849402364 190836612 -734236782 92102111 -789483305 830557929 771609132 388421794 35344406 700584635 839513357 -392027489 651587976 579583693 -740753197 -732496179 -814246009 255540447 -21519475 333233308 -935862885 557699013 -142212816 182576414 736445671 -407422613 -443114894 -556185485 64…
Output: 981383437 981383437 981383437 981977002 161929563 161929563 683935777 61223631 683935777 981977002 981977002 -391400153 981977002 -505825209 981977002 983042172 951202852 951202852 972442117 534941380 10033932 534941380 650697785 732495986 732495986 732495986 884823089 884823089 884823089 972442117 -350656504 -54478278 814656580 972442117 139145465 627119368 -126430324 94284330 627119368 627119368 776414896 219980051 776414896 972442117 972442117 974647326 849402364 151020403 849402364 951851402 830557929 92102111 830557929 830557929 839513357 839513357 700584635 700584635 839513357 951851402 651587976 736445671 736445671 -732496179 255540447 255540447 333233308 333233308 557699013 557699013 736445671 182576414 736445671 755834599 645900661 645900661 645900661 755834599 -182634645 64399697…

Example 3:

Input: 2224 325021078 -946810814 -117285523 263080068 782467823 -180440435 -341931492 503150852 -132023353 -721730512 -274294869 877049746 703436572 -153722726 -827972670 -789161984 -701847799 -893208038 765456826 999741484 2840601 -547034947 -843364776 -195769682 -627861294 420336614 -493565000 194633228 494886495 476507844 942176086 -537799795 -550454499 126614377 913794238 -199043294 -64984043 -294774482 897163941 -357375901 704661384 377967816 42303433 -962192635 149063474 -420792436 -233391038 979238102 -38744092 141555745 764086745 -727151197 792733737 225745550 978964461 -324429040 -884130764 -586984283 -926118088 307150660 337388972 -63360555 542204472 90441252 -140896663 292203904 -596971191 -658902035 981772254 477435135 19072870 -85253664 877050866 -658149160 577879689 -334308870 69999…
Output: 782467823 -117285523 263080068 782467823 877049746 503150852 503150852 877049746 877049746 -274294869 877049746 999741484 765456826 765456826 -789161984 -701847799 765456826 765456826 999741484 -1 420336614 -195769682 -195769682 420336614 420336614 494886495 194633228 494886495 942176086 942176086 979238102 126614377 126614377 913794238 979238102 -64984043 897163941 897163941 979238102 704661384 979238102 979238102 149063474 149063474 979238102 -233391038 979238102 981772254 141555745 764086745 792733737 792733737 978964461 978964461 981772254 307150660 -586984283 307150660 307150660 337388972 542204472 542204472 981772254 292203904 292203904 981772254 981772254 981772254 993003944 877050866 877050866 877050866 960937603 577879689 960937603 69999678 960937603 993003944 993003944 642248558 …

Constraints:

1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
The Mossy ledgers of Petra - MEDIUM Coding Problem | CodeTikki