CT49720

Pia and the Lazy ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the desert outpost of Sandspire opens only for a perfect tally of ledgers. Pia 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: 3981 351140587 -180063947 955152485 682447887 708829424 86701345 114560531 -56159884 -34620825 715092896 942863701 106427034 240520291 714302735 547065689 -768844022 -77505522 294183340 816824506 -532346199 -417069879 -352060425 683113397 -747981805 308460347 242373703 291056272 304551746 202099355 -736748109 -855464401 -614592377 29883396 907293125 -27574581 -68423282 817495905 294736989 -881765389 743568985 -622771758 937074842 -193701410 -378185622 481503713 -114666969 430452091 161418786 -16659445 684192503 491673480 -163546361 602579064 96837982 266996119 -272012383 483467159 -667401981 -273107491 590404685 60152728 311016632 797566292 -606220759 -425086024 796301031 -479727863 262565107 -200539187 -938919708 -467222079 -461772080 -280657635 -201233645 -828468426 -843669224 581317117 …
Output: 955152485 955152485 986146828 708829424 715092896 114560531 715092896 -34620825 715092896 942863701 986146828 240520291 714302735 816824506 816824506 -77505522 294183340 816824506 907293125 -417069879 -352060425 683113397 907293125 308460347 907293125 291056272 304551746 907293125 907293125 -614592377 -614592377 29883396 907293125 937074842 817495905 817495905 937074842 743568985 743568985 937074842 937074842 986146828 481503713 481503713 684192503 430452091 684192503 684192503 684192503 797566292 602579064 602579064 797566292 266996119 483467159 483467159 590404685 -273107491 590404685 797566292 311016632 797566292 986146828 -425086024 796301031 986146828 262565107 581317117 581317117 -467222079 -461772080 -280657635 -201233645 581317117 581317117 581317117 634549764 986146828 986146828 9…

Example 2:

Input: 2156 -630623650 -525019451 696417921 -133221025 949404551 -573483653 180250053 437223218 -963872358 940281769 -663169731 -745535147 636819627 -770651214 -564672120 633199870 -203386772 -957737635 -371334006 -589154681 740551896 73579099 551532360 713190747 813524162 480930210 -907069153 -127906710 -490595551 811095156 142203184 -724636582 -549852792 -263070626 483650681 488553215 901628127 138868242 -455205242 -884823055 -973001462 -209774345 -322689414 -478665289 643015015 229046972 -201045338 373826512 -665922844 477843344 -563660775 894678416 263444731 680803316 -890120726 785052041 797195692 -829429034 852096215 284089406 -919074442 647298354 260003689 396149129 -781121535 -914775454 370828494 -875695272 27000102 -275562734 -924672816 -671618214 -323412175 -379431854 377762479 -1881141…
Output: -525019451 696417921 949404551 949404551 979606581 180250053 437223218 940281769 940281769 979606581 636819627 636819627 740551896 -564672120 633199870 740551896 740551896 -371334006 740551896 740551896 813524162 551532360 713190747 813524162 901628127 811095156 -127906710 811095156 811095156 901628127 483650681 -549852792 -263070626 483650681 488553215 901628127 979606581 643015015 -209774345 -209774345 -209774345 643015015 643015015 643015015 894678416 373826512 373826512 477843344 477843344 894678416 894678416 979606581 680803316 785052041 785052041 797195692 852096215 852096215 979606581 647298354 647298354 979606581 396149129 589577675 370828494 370828494 377762479 27000102 377762479 377762479 -671618214 -323412175 377762479 377762479 589577675 589577675 626789830 626789830 626789830 …

Example 3:

Input: 2299 474805457 -432814996 311020542 668491205 -953491284 -454060552 -487178364 69993392 437892745 -862333604 -757003761 -164865117 -930293210 -921805873 -509111005 987302230 -153080738 262526796 -992293515 730401185 -303279522 712985425 -521827063 893926969 398289457 -96985549 -84684785 432947459 -384284191 763230276 -401157277 -967143275 750195318 -411363064 -50235502 143770341 -947468095 -99505965 115964013 23624398 10934033 -817539175 -856623518 501077211 553812576 -103258244 -277393429 -683241159 -978744007 874028260 -299607422 -290556182 -396688290 -426373447 -183636693 894100160 -662864782 424180476 -795366490 -495462944 -68645611 570658008 -691013173 -248586985 143046989 -315751959 -329314848 -658513592 -342718783 -121677940 453686625 -265269863 676637529 976742339 518330078 7420888…
Output: 668491205 311020542 668491205 987302230 -454060552 69993392 69993392 437892745 987302230 -757003761 -164865117 987302230 -921805873 -509111005 987302230 988902093 262526796 730401185 730401185 893926969 712985425 893926969 893926969 894100160 432947459 -84684785 432947459 763230276 763230276 874028260 750195318 750195318 874028260 -50235502 143770341 501077211 -99505965 115964013 501077211 501077211 501077211 501077211 501077211 553812576 874028260 874028260 874028260 874028260 874028260 894100160 -290556182 -183636693 -183636693 -183636693 894100160 976742339 424180476 570658008 -495462944 -68645611 570658008 676637529 -248586985 143046989 453686625 -121677940 -121677940 -342718783 -121677940 453686625 676637529 676637529 976742339 984954283 742088809 792487361 792487361 951843509 2460318…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Pia and the Lazy ledgers - MEDIUM Coding Problem | CodeTikki