CT42299

The Taller Ahead of the Sunlit ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Manav found an old ledger of ledgers in the archive attic at the bamboo terraces of Verdantstep. The margin notes pose a precise question. 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: 1976 -301159143 619052135 -559035844 -494102048 203070644 -850041556 858101754 -36254347 757619876 -33450 -837499087 -344003824 92730866 740476437 44761362 -705948681 585071233 508937960 131528604 -851264612 768383929 906133490 782182471 -841165640 -27910534 -95345326 699673987 510291888 522456067 -727100861 -799890005 -248837876 -506583464 760240993 -600117212 251126983 -909303361 -344986082 803488407 294764877 -397285698 793970942 123434004 677172512 -498150438 -712832773 -559332449 473204850 593821501 -987953689 642270765 -60403544 962290602 -286571764 166458888 969570395 234561914 -452065287 175733743 474317282 188515380 -820108533 -946820870 -409309230 42332369 -688051360 774544932 870694310 371189493 471091218 -422597180 -871021281 788416142 -312454817 799893625 -395670805 635006564 …
Output: 619052135 858101754 -494102048 203070644 858101754 858101754 906133490 757619876 768383929 92730866 -344003824 92730866 740476437 768383929 585071233 585071233 768383929 768383929 768383929 768383929 906133490 962290602 803488407 -27910534 699673987 699673987 760240993 522456067 760240993 -248837876 -248837876 760240993 760240993 803488407 251126983 803488407 -344986082 803488407 962290602 793970942 793970942 962290602 677172512 962290602 473204850 -559332449 473204850 593821501 642270765 642270765 962290602 962290602 969570395 166458888 969570395 989835805 474317282 175733743 474317282 774544932 774544932 -409309230 -409309230 42332369 774544932 774544932 870694310 943771188 471091218 788416142 788416142 788416142 799893625 799893625 829094639 635006564 770790168 770790168 770790168 77079…

Example 2:

Input: 3656 838392498 -646133316 -457879630 -799446647 -822996417 -912434692 -247691275 898541575 -115325404 280509419 662358678 -728369122 -966831339 453737236 -410990887 -561254278 883836506 534683891 125565940 137610794 -888050 591235038 -564328036 -378768119 581373532 785273361 -398558827 -872287390 -134704463 185687350 849559342 259415882 -691764278 -758056480 459031156 -418532181 -29882774 -428111799 -531040768 218828554 527305330 796183646 -157202431 -700821661 183141017 -635574628 -836941319 596294536 9365242 -659640915 -368087243 -191911987 -877783359 -740432168 -513999231 -77390554 687217420 -937361535 -392774746 675039625 -70146371 -966145838 -405087140 442821156 950191539 733205974 -460321872 -912326161 -86334232 523574657 29130231 834991032 391024922 -845672355 741844828 -970199148 -…
Output: 898541575 -457879630 -247691275 -247691275 -247691275 -247691275 898541575 950191539 280509419 662358678 883836506 453737236 453737236 883836506 883836506 883836506 950191539 591235038 137610794 591235038 591235038 785273361 -378768119 581373532 785273361 849559342 -134704463 -134704463 185687350 849559342 950191539 459031156 459031156 459031156 527305330 -29882774 218828554 218828554 218828554 527305330 796183646 950191539 183141017 183141017 596294536 596294536 596294536 687217420 687217420 -368087243 -191911987 -77390554 -740432168 -513999231 -77390554 687217420 950191539 -392774746 675039625 950191539 442821156 -405087140 442821156 950191539 984659966 834991032 -86334232 -86334232 523574657 834991032 834991032 915286120 741844828 741844828 915286120 -724921339 915286120 915286120 98465…

Example 3:

Input: 1981 -597446524 659524993 451154888 710757240 894298940 -817228660 906388576 -933876447 196946730 -627223963 -530173345 124341307 993415433 -639500731 620387252 -931610971 -961352922 -863913978 659370776 362787708 298868245 737625257 -686213727 264050695 376941506 -768238582 71156442 883059750 121328373 -778722452 -403436681 -769464087 260745575 51075691 -350302905 868617604 493596180 338086410 938202517 -837139603 433819856 -781055967 924912318 -665603889 321907287 310286192 390896278 927325297 -645899240 698513282 -150756973 8604727 604581066 693517283 -848126561 -527614225 916069326 -551428160 78239022 746432684 -644198584 208821651 -895549211 209977776 755602146 -913958245 460612804 -845065571 -407226844 -468179347 653965680 98110061 58657962 374999992 848130296 -929887315 343119212 -9…
Output: 659524993 710757240 710757240 894298940 906388576 906388576 993415433 196946730 993415433 -530173345 124341307 993415433 997637529 620387252 659370776 -863913978 -863913978 659370776 737625257 737625257 737625257 883059750 264050695 376941506 883059750 71156442 883059750 938202517 260745575 -403436681 260745575 260745575 868617604 868617604 868617604 938202517 938202517 938202517 965194672 433819856 924912318 924912318 927325297 321907287 390896278 390896278 927325297 965194672 698513282 916069326 8604727 604581066 693517283 916069326 -527614225 916069326 965194672 78239022 746432684 755602146 208821651 209977776 209977776 755602146 848130296 460612804 653965680 -407226844 653965680 653965680 848130296 374999992 374999992 848130296 965194672 343119212 402711586 402711586 965194672 96519467…

Constraints:

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

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