CT40879

Finn's ledgers Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The log keeper Finn has been asked to document the rare sighting. On the desk lies a long table of ledgers 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: 3828 145630615 134928315 342410768 -586757281 -866199459 -236817252 512435984 463607773 -768899652 -476648368 177979258 482201688 -836948930 812959158 672315089 -719148127 494704947 -301753656 -237463302 -303332351 -700190118 617956099 -822382428 304816094 759742909 -233528281 147812864 -683519340 -472645648 -907374451 162023488 585953197 83209426 51638607 -554266678 -181666548 -750372107 124816804 -336877541 -185021628 950139243 -357474943 -804609573 -916635037 -494421100 -786368611 648896877 440013083 38689825 -365702889 -904372709 799418106 -502069032 784526579 650950460 -689493208 521764083 -93896539 -358513023 -866934905 -188523108 279257325 509949526 -393260394 39440171 -777858747 210205985 -444000143 492677328 -141007158 -238216861 189800789 264492782 277343469 -52882540 -557379107 …
Output: 342410768 342410768 512435984 -236817252 -236817252 512435984 812959158 482201688 -476648368 177979258 482201688 812959158 812959158 950139243 759742909 494704947 617956099 -237463302 617956099 617956099 617956099 759742909 304816094 759742909 950139243 147812864 162023488 -472645648 162023488 162023488 585953197 950139243 124816804 124816804 -181666548 124816804 124816804 950139243 -185021628 950139243 972807190 648896877 -494421100 -494421100 648896877 648896877 799418106 799418106 799418106 799418106 799418106 972807190 784526579 972807190 972807190 521764083 972807190 279257325 -188523108 -188523108 279257325 509949526 516403816 39440171 210205985 210205985 492677328 492677328 516403816 189800789 189800789 264492782 277343469 516403816 259267148 -323652013 259267148 259267148 273671222…

Example 2:

Input: 361 882216689 450550296 419064628 -753842524 378208200 839756751 238316504 558445742 520909666 -568493462 477294885 -211577242 357523778 381976388 -691231236 562433508 444829198 444584845 -105781655 -67421096 45924747 397965476 -929470467 930799234 -434415927 -157455613 -699504761 -181465090 -977021164 192930650 664273780 -249661582 32058042 -357327763 -134300691 974144181 -32246449 457883319 981762762 931066883 -671645419 308233607 -961500976 311414704 -418329151 -592904173 761665802 666847147 667113435 -724909241 -770135712 -466028824 731858202 36934982 393591364 -459867689 -80369866 113096961 -311055895 99238740 288207978 262120491 796689989 -772805610 97058618 895017201 167063014 643636499 561524453 -718679926 -172162311 287067 251414187 -297460329 771952047 -218084644 332760549 -95647…
Output: 930799234 839756751 839756751 378208200 839756751 930799234 558445742 562433508 562433508 477294885 562433508 357523778 381976388 562433508 562433508 930799234 930799234 930799234 -67421096 45924747 397965476 930799234 930799234 974144181 -157455613 192930650 -181465090 192930650 192930650 664273780 974144181 32058042 974144181 -134300691 974144181 981762762 457883319 981762762 984818961 971020343 308233607 311414704 311414704 761665802 761665802 761665802 796689989 667113435 731858202 -466028824 -466028824 731858202 796689989 393591364 796689989 -80369866 113096961 288207978 99238740 288207978 796689989 796689989 895017201 97058618 895017201 905606755 643636499 771952047 771952047 -172162311 287067 251414187 771952047 771952047 905606755 332760549 495472298 495472298 905606755 905606755 9…

Example 3:

Input: 1594 148205145 -709110377 447570696 -172664564 -347530001 -448991793 137998899 -502885214 -169186405 -537752033 -956209694 -554221447 -988287620 714985621 -66018530 -568978544 -764517116 915164241 825282698 9503990 -9636819 -553698385 -906265060 632079064 607573255 -181341868 -93203097 238724002 -143873498 -293968918 420041114 308220440 263583576 241397173 3638921 110430860 484922952 -118161864 631419058 -380197599 -986766527 724004922 810283422 -598992202 -360381897 950153923 806787903 235002536 260798386 540354218 96554561 441641193 441960590 866163 307176116 -500662142 -927854460 512111326 -875750543 -926198878 -823238173 520751550 853517443 -673255024 -233526607 573641386 -40942702 875754815 -712003435 -902013578 693421945 -999983274 -261211991 288822359 -865891665 -830832159 -12485398…
Output: 447570696 447570696 714985621 137998899 137998899 137998899 714985621 -169186405 714985621 714985621 -554221447 714985621 714985621 915164241 915164241 915164241 915164241 950153923 950153923 632079064 632079064 632079064 632079064 724004922 631419058 -93203097 238724002 420041114 420041114 420041114 484922952 484922952 484922952 484922952 110430860 484922952 631419058 631419058 724004922 724004922 724004922 810283422 950153923 -360381897 950153923 973547085 853517443 260798386 540354218 853517443 441641193 441960590 512111326 307176116 512111326 512111326 512111326 520751550 -823238173 -823238173 520751550 853517443 875754815 -233526607 573641386 875754815 875754815 973547085 693421945 693421945 742463929 -261211991 288822359 742463929 -830832159 -12485398 742463929 973547085 713522030 71…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Finn's ledgers Taller Ahead - MEDIUM Coding Problem | CodeTikki