CT35488

The Taller Ahead of Vineward

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Lysander the store warden watches over the ivy courts of Vineward's stores of registers. A careful computation stands between order and chaos. 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: 312 568047175 -939231481 -108776617 86049528 56871789 912697034 -468929264 -288074428 629173307 552630574 795821307 -874426953 764731290 -68081423 -692034587 -268010139 632099842 808035556 -892465907 88316261 -973260514 125648262 460072631 -286625265 522745369 -976724465 550618520 914723193 -757179072 -243830827 -47705610 -995230172 -554370957 163193239 -124322272 353047403 -759123077 -548533859 -820055435 -401306221 437130409 943541220 731445446 -383262669 566724035 -481471648 -308864654 78941339 797686359 372610793 148874727 477084791 -685440843 31472605 -380852309 866013796 -106449346 823602887 -39109165 -35110955 356624641 25325506 -387298005 433067260 997759186 715249849 -408512579 936244558 -803483397 -506191072 159989375 -365285373 -205161957 -603569648 371637166 -435248284 -7367112…
Output: 912697034 -108776617 86049528 912697034 912697034 914723193 -288074428 629173307 795821307 795821307 808035556 764731290 808035556 632099842 -268010139 632099842 808035556 914723193 88316261 125648262 125648262 460072631 522745369 522745369 550618520 550618520 914723193 943541220 -243830827 -47705610 163193239 -554370957 163193239 353047403 353047403 437130409 -548533859 -401306221 -401306221 437130409 943541220 997759186 797686359 566724035 797686359 -308864654 78941339 797686359 866013796 477084791 477084791 866013796 31472605 866013796 866013796 997759186 823602887 997759186 -35110955 356624641 433067260 433067260 433067260 997759186 -1 936244558 936244558 980856110 -506191072 159989375 371637166 -205161957 371637166 371637166 676220691 -383000480 -383000480 -72141798 676220691 79172952…

Example 2:

Input: 235 -682537860 48649289 426205095 744869052 155135540 -372465424 -435023907 -952599078 -867554610 -149525245 777442466 323607281 -915405685 451888666 -87853312 169348256 -839026502 182728744 -212898696 -47058682 -746830536 -484310554 -705783324 76168801 -405387339 -930521623 595166703 462976304 436141914 612322522 -929072316 788150492 40743803 151905789 -678341463 425175260 179853069 38083382 160823716 170189583 -614886259 -933017831 -547769728 111557798 -618305644 -706858353 121385641 994425763 168046035 -409797953 -147668503 209144516 -644247356 -999048423 -72007936 666434455 857025970 48952476 -377794667 -380843315 54776396 170518712 -173900922 717919225 17523735 997821327 -990265559 -918176794 -467676445 -549355971 759315143 -641198551 839630345 904878040 331353167 766393495 576631845 …
Output: 48649289 426205095 744869052 777442466 777442466 -149525245 -149525245 -867554610 -149525245 777442466 788150492 451888666 451888666 595166703 169348256 182728744 182728744 595166703 -47058682 76168801 -484310554 76168801 76168801 595166703 595166703 595166703 612322522 612322522 612322522 788150492 788150492 994425763 151905789 425175260 425175260 994425763 994425763 160823716 170189583 994425763 -547769728 -547769728 111557798 121385641 121385641 121385641 994425763 997821327 209144516 -147668503 209144516 666434455 -72007936 -72007936 666434455 857025970 997821327 54776396 54776396 54776396 170518712 717919225 717919225 997821327 997821327 -1 -918176794 -467676445 759315143 759315143 839630345 839630345 904878040 988865970 766393495 901773956 698018871 537475930 698018871 901773956 9888…

Example 3:

Input: 1676 -466900187 -499571093 34199365 408501320 691562887 681453595 781653235 -124906262 -688250604 932932173 -409728224 -534954095 -795217556 671820477 -990787150 -355812817 635482753 789154547 679618040 -541876478 86747006 676259178 -609584167 471070833 386984511 -425937889 -698235981 -994667485 -887772858 604255472 -737870626 946081947 505397268 -199840034 -392056230 85029078 -848606413 -319929611 282312458 -615302047 -868303205 -418195643 548016087 -630064060 957364734 -104684109 123323366 387143833 584352045 -636747241 738537341 196912333 -811024340 -711364540 -946853977 -646695947 624949711 -309121751 9357268 55035048 297810447 -137727887 253986537 106675871 -670776540 -181144923 -908491131 168175692 -906488424 -511708948 -418003637 936833022 -241418925 -993926200 -704187204 773644428 …
Output: 34199365 34199365 408501320 691562887 781653235 781653235 932932173 932932173 932932173 946081947 671820477 671820477 671820477 789154547 -355812817 635482753 789154547 946081947 946081947 86747006 676259178 946081947 471070833 604255472 604255472 604255472 604255472 -887772858 604255472 946081947 946081947 957364734 548016087 85029078 85029078 282312458 -319929611 282312458 548016087 -418195643 -418195643 548016087 957364734 957364734 957665054 123323366 387143833 584352045 738537341 738537341 936833022 624949711 -711364540 -646695947 -646695947 624949711 936833022 9357268 55035048 297810447 936833022 253986537 936833022 168175692 -181144923 168175692 168175692 936833022 -511708948 -418003637 936833022 954841192 773644428 -704187204 773644428 850880628 902032080 747331074 902032080 -19197…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Taller Ahead of Vineward - MEDIUM Coding Problem | CodeTikki