CT54292

The Timeworn Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The quartermaster Lila has been asked to certify the cargo before shipping. On the desk lies a long table of registers 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: 1374 -334078882 551758139 -393605313 -340654773 -50833424 956854464 -996902544 -443779308 -772365868 -306872495 71157176 978605591 586358890 741246883 -768748474 24504310 278760135 -360674468 778056259 220632474 -412530641 890522788 -603275670 860639710 198362365 214434618 119604469 615365694 53213171 -806256917 -326472466 33021625 -79618481 -233034152 88312001 45392490 -120005026 684726382 -392418074 329849417 -787971412 -710696321 751934417 -209449271 -133891358 -147047791 597806480 -933759409 -812164259 -309185135 987920320 -821018504 -742890464 -702168174 314141928 -629566071 -922130200 266860484 800769747 264569627 -369067671 -354190178 421187679 350153110 594658106 -947512478 136003492 20299224 -240660158 664486430 -461567977 664427963 100607747 279412183 -623044463 -617050188 -72727…
Output: 551758139 956854464 -340654773 -50833424 956854464 978605591 -443779308 -306872495 -306872495 71157176 978605591 987920320 741246883 778056259 24504310 278760135 778056259 778056259 890522788 890522788 890522788 987920320 860639710 987920320 214434618 615365694 615365694 684726382 88312001 -326472466 33021625 88312001 88312001 88312001 684726382 684726382 684726382 751934417 329849417 751934417 -710696321 751934417 987920320 -133891358 597806480 597806480 987920320 -812164259 -309185135 987920320 998315667 -742890464 -702168174 314141928 800769747 266860484 266860484 800769747 840445801 421187679 -354190178 421187679 594658106 594658106 664486430 136003492 664486430 664486430 664486430 700258661 664427963 700258661 279412183 351097423 -617050188 -361747738 -361747738 -215358819 -111280751 …

Example 2:

Input: 3076 407182954 -446320997 477605488 762255756 103386212 757805109 718608775 -268039062 48307253 351880186 15230421 -211019121 752833078 -345284623 -273435524 257848379 -232434216 279012376 852457120 135546484 704369221 -50679069 771885681 903310343 811969224 279686650 -700275445 357375842 -727558999 91828015 76397627 -774848660 924924244 -35294626 -679420580 -452024408 -321282562 426982109 865292063 144276206 -38024944 842629890 539234730 -590940436 817043553 939609915 731531333 -173821739 -160560396 778841148 -716947165 -657252521 63095975 535554629 784521459 -309983935 474891607 -236059598 692279458 158715895 81246024 404456887 -27976594 979564207 256461461 -101383579 772799929 230953247 -155068150 930632214 -236152590 -234162233 482586425 -964004178 967342911 -757736686 -797409026 90155…
Output: 477605488 477605488 762255756 852457120 757805109 852457120 752833078 48307253 351880186 752833078 752833078 752833078 852457120 -273435524 257848379 279012376 279012376 852457120 903310343 704369221 771885681 771885681 903310343 924924244 924924244 357375842 357375842 924924244 91828015 924924244 924924244 924924244 939609915 426982109 -452024408 -321282562 426982109 865292063 939609915 842629890 842629890 939609915 817043553 817043553 939609915 979564207 778841148 -160560396 778841148 784521459 -657252521 63095975 535554629 784521459 979564207 474891607 692279458 692279458 979564207 404456887 404456887 979564207 979564207 999327516 772799929 772799929 930632214 930632214 930632214 967342911 -234162233 482586425 967342911 967342911 999327516 901550390 901550390 999327516 882254448 6146744…

Example 3:

Input: 2303 125391562 41496280 -150491950 327502348 -265023022 -993611227 758434945 314632799 -103159458 -940388858 832011452 684034828 -362040907 -52015864 203990328 -965279261 -709398103 -622182357 -246119700 793247054 -800266017 -5982401 796937846 260593 287907512 -264362700 112181558 333516521 -246496648 17929557 180319607 97603890 871014986 361283635 570188722 -156777101 167202501 -888846094 -20039886 996645951 -798748660 419646908 -542736191 -287323367 966809560 796773846 482656054 761379833 503272745 -332724738 -514813134 848825072 -953513237 -513044719 -766206203 -513674945 -60738923 -59246688 -658937656 -995132053 140822051 -363588694 621620342 493862035 176313291 -493737843 -100276672 -789105333 -475291175 -63933895 918628115 -769852974 922120333 317226893 555491574 -167445352 -30016762…
Output: 327502348 327502348 327502348 758434945 758434945 758434945 832011452 832011452 832011452 832011452 871014986 793247054 -52015864 203990328 793247054 -709398103 -622182357 -246119700 793247054 796937846 -5982401 796937846 871014986 287907512 333516521 112181558 333516521 871014986 17929557 180319607 871014986 871014986 996645951 570188722 996645951 167202501 996645951 -20039886 996645951 998499300 419646908 966809560 -287323367 966809560 976194736 848825072 761379833 848825072 848825072 848825072 848825072 918628115 -513044719 -60738923 -513674945 -60738923 -59246688 140822051 140822051 140822051 621620342 621620342 918628115 918628115 918628115 -100276672 -63933895 -475291175 -63933895 918628115 922120333 922120333 976194736 555491574 819648222 819648222 819648222 835036242 532677897 6476…

Constraints:

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

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