CT46397

The Shimmerdeep Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the opal reefs of Shimmerdeep close for winter, Elsa must finish the beacons ledger - one figure at a time. 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: 621 826118164 -240100088 -975470854 -429925194 372819330 119760854 -706750313 130828381 799168294 -867649165 -84154914 110823120 -700481378 -995198042 283814579 274851863 -722712191 83228932 151105629 -387774441 289263273 975609698 559051672 -815822304 757820151 872519170 802908485 789006168 628091703 819331932 -383930838 -871248088 329227472 -362603401 -327951141 639816434 529473974 618324285 -615893250 -285721413 623912796 -289706690 -535102070 117019037 821436843 570627086 752923981 590272437 603210458 -717148847 -687837934 -768701064 798310524 158516992 483007068 -989173539 947969398 -294876396 -722204720 -636620509 -586069839 -767373985 -423513180 -527433713 -96096997 385282766 -713980715 -531461728 460697125 -133758883 -653832584 -861919649 -547200849 701689784 -605810383 438054103 -…
Output: 975609698 372819330 -429925194 372819330 799168294 130828381 130828381 799168294 975609698 -84154914 110823120 283814579 283814579 283814579 289263273 289263273 83228932 151105629 289263273 289263273 975609698 976280579 757820151 757820151 872519170 947969398 819331932 819331932 819331932 821436843 329227472 329227472 639816434 -327951141 639816434 821436843 618324285 623912796 -285721413 623912796 821436843 117019037 117019037 821436843 947969398 752923981 798310524 603210458 798310524 -687837934 798310524 798310524 947969398 483007068 947969398 947969398 976280579 -96096997 -636620509 -586069839 -423513180 -423513180 -96096997 -96096997 385282766 460697125 -531461728 460697125 701689784 701689784 -547200849 -547200849 701689784 926914849 438054103 540414246 -640631685 -318462618 21792655…

Example 2:

Input: 953 -247817006 -194078566 -475794594 -316062969 -388785734 874563317 346243727 -63248770 -178325096 -183911878 294105767 -818842861 923219024 -476953929 848201147 220892491 965245822 58578488 -305504236 -942914165 904978281 885525478 979766785 -192864629 -478072409 -807476860 297788680 579855248 -319848120 624305390 -359120695 389065338 781744656 797993633 -677150927 337998268 627214674 -939073586 -406023207 -33021684 813779993 -758234925 -216239532 -607151344 528323595 -183852113 -462432776 -801563714 947826073 37666964 -993798132 -110635400 223475197 -372393007 846901643 -24557004 -349693405 -370219371 860586805 280135033 -956012854 -186625210 492441990 633555267 313667480 -76364438 -766169842 143915054 -597913868 -952978461 790719447 458771129 -955825617 -741345417 -675082283 -79121651 …
Output: -194078566 874563317 -316062969 874563317 874563317 923219024 923219024 294105767 294105767 294105767 923219024 923219024 965245822 848201147 965245822 965245822 979766785 904978281 904978281 904978281 979766785 979766785 983806512 297788680 297788680 297788680 579855248 624305390 624305390 781744656 389065338 781744656 797993633 813779993 337998268 627214674 813779993 -406023207 -33021684 813779993 947826073 -216239532 528323595 528323595 947826073 947826073 947826073 947826073 983806512 223475197 -110635400 223475197 846901643 846901643 860586805 860586805 860586805 860586805 903100129 492441990 -186625210 492441990 633555267 790719447 790719447 143915054 143915054 790719447 790719447 790719447 903100129 488641221 -741345417 -675082283 -79121651 96443027 453957270 453957270 453957270 488…

Example 3:

Input: 883 -404538597 485078919 -60952855 -965873294 -339207628 134347692 433820536 366714790 846486996 24301412 -553304281 -958739636 -239244679 838600075 -657682868 671922168 -744454358 914973356 375515019 859314110 -575334678 -80457808 291773968 120871375 -641179483 -913202487 -193295852 697000522 921197912 -395573024 175172479 -785158855 575152363 708253042 -977287704 609883208 -663247106 393275170 327582743 -681723791 292733888 185481003 29622582 -829835990 -385645433 -861053116 838194275 913576789 487147158 -386649818 -531634371 595591823 -987004562 -585903619 792757039 96156379 -402520657 -793443300 -321928532 -867680486 -538075308 141920473 825138877 -72042453 -72379117 -761662446 -412738653 311518115 -731585682 511618482 924827048 -161474714 457106972 -293105716 129252927 -759308276 -147…
Output: 485078919 846486996 134347692 -339207628 134347692 433820536 846486996 846486996 914973356 838600075 -239244679 -239244679 838600075 914973356 671922168 914973356 914973356 921197912 859314110 921197912 -80457808 291773968 697000522 697000522 -193295852 -193295852 697000522 921197912 924827048 175172479 575152363 575152363 708253042 838194275 609883208 838194275 393275170 838194275 838194275 292733888 838194275 838194275 838194275 -385645433 838194275 838194275 913576789 924827048 595591823 595591823 595591823 792757039 -585903619 792757039 825138877 141920473 -321928532 -321928532 141920473 -538075308 141920473 825138877 924827048 311518115 311518115 -412738653 311518115 511618482 511618482 924827048 975338344 457106972 629322066 129252927 629322066 -147023148 -134237085 629322066 -576143…

Constraints:

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

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