CT55695

Marble ledgers Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the silver mines of Lodebarrow opens only for a perfect tally of ledgers. Theo means to find out. 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: 1537 -382858232 248056005 -244727127 -299005505 -386418759 -397096842 -952051786 912222797 448442662 -172927956 155626198 322302997 -207973508 -670174515 -340455413 -877409593 820957581 -275587168 -512004793 87729480 -901521495 142043297 831622567 449508078 -348184154 406397638 -676967 -619846941 -86121178 -851333041 238400752 -816060283 553750597 -286104169 281306433 922247655 -586933840 -447704784 -289286081 750731959 -341199933 -119527620 -235641538 672243060 -271809528 941793947 690684722 -924704938 -421610422 998887067 -110603566 146452641 -184725390 776039132 111514525 -761326882 602929804 68987490 967038890 -453630531 -891608506 -26091883 -956021802 -887431936 -147420587 -278265751 803365657 -481037519 -119485847 68271824 -393228313 -980034015 -202728986 -424024752 646945836 4522608…
Output: 248056005 912222797 912222797 912222797 912222797 912222797 912222797 922247655 820957581 155626198 322302997 820957581 820957581 -340455413 820957581 820957581 831622567 87729480 87729480 142043297 142043297 831622567 922247655 553750597 406397638 553750597 238400752 -86121178 238400752 238400752 553750597 553750597 922247655 281306433 922247655 941793947 -447704784 -289286081 750731959 941793947 -119527620 672243060 672243060 941793947 941793947 998887067 998887067 -421610422 998887067 -1 146452641 776039132 776039132 967038890 602929804 602929804 967038890 967038890 979854190 -26091883 -26091883 803365657 -887431936 -147420587 803365657 803365657 926356804 -119485847 68271824 646945836 -202728986 -202728986 646945836 646945836 926356804 926356804 926356804 948817532 287389115 791088718 …

Example 2:

Input: 785 -813619206 -292842473 -727827070 285826346 -748333934 227388515 -854050119 -722451220 -413197920 266405221 132206262 -473191259 -671800537 -777802337 -108346710 -241188632 -230919132 917550504 -144194417 -460038739 986909913 650711925 -863425376 734576551 410748735 -664289477 406972134 358183826 -573516850 -866038537 -388558125 545507466 389044946 275181027 786941036 -703268364 294022572 -974441484 608272666 29846603 306970348 -257679813 868047169 -827053752 -747835863 425560066 -216589430 943062257 -22683895 710336345 502783939 -188095221 667197978 189822863 -881063393 823601531 -365681737 -163868864 -297019570 56409441 -775883315 98266889 -295979656 -243466664 540313035 934554925 801033747 929713114 -455391419 298794362 -907755058 515973042 197984857 -909056585 194628466 -799581944 3…
Output: -292842473 285826346 285826346 917550504 227388515 266405221 -722451220 -413197920 266405221 917550504 917550504 -108346710 -108346710 -108346710 917550504 -230919132 917550504 986909913 986909913 986909913 999676013 734576551 734576551 786941036 545507466 406972134 545507466 545507466 -388558125 -388558125 545507466 786941036 786941036 786941036 868047169 294022572 608272666 608272666 868047169 306970348 868047169 868047169 943062257 -747835863 425560066 943062257 943062257 999676013 710336345 823601531 667197978 667197978 823601531 823601531 823601531 934554925 -163868864 56409441 56409441 98266889 98266889 540313035 -243466664 540313035 934554925 999676013 929713114 999676013 298794362 515973042 515973042 567970236 313936833 194628466 313936833 313936833 567970236 567970236 999676013 -1…

Example 3:

Input: 1546 658715651 -989388197 -325074368 -745448997 135807827 -988670147 -917746212 312426748 494062065 375196556 -897075676 490300643 -904906886 175287000 311668738 22415451 -512530701 963518178 -888059574 -77790648 965657624 154305579 -124398481 744313001 -85727207 -351862590 -442723834 691930616 -749194983 978625362 839017575 71873915 -718715308 379016444 814660166 450072738 -314591630 -876164258 967868360 -740239215 -674559892 442489670 -397473477 28665464 251007192 581414367 147949035 -871990483 -570428248 -242342145 -294648579 -879665556 264024882 -372285544 753417560 -410500584 -428620712 -690340483 -808795370 -703954954 -322211143 916336824 404773183 132243837 435898379 909340024 424013108 -738429849 605523977 340792254 88679747 717546785 647260702 461337725 942041111 973397102 2382382…
Output: 963518178 -325074368 135807827 135807827 312426748 -917746212 312426748 494062065 963518178 490300643 490300643 963518178 175287000 311668738 963518178 963518178 963518178 965657624 -77790648 965657624 978625362 744313001 744313001 978625362 691930616 691930616 691930616 978625362 978625362 984890746 967868360 379016444 379016444 814660166 967868360 967868360 967868360 967868360 973397102 -674559892 442489670 581414367 28665464 251007192 581414367 753417560 264024882 -570428248 -242342145 264024882 264024882 264024882 753417560 753417560 916336824 -322211143 -322211143 -322211143 -703954954 -322211143 916336824 942041111 435898379 435898379 909340024 942041111 605523977 605523977 717546785 717546785 717546785 942041111 942041111 942041111 973397102 974470575 974470575 974470575 984890746 -…

Constraints:

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

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