CT53447

Owen and the Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the dune sea of Caravanrest opens only for a perfect tally of ledgers. Owen 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: 751 -766825333 616538530 -796029768 -755072236 -39440678 -844671205 243723780 -621218434 -860629117 123390487 489335224 -249936753 818881821 -129571037 -231576828 145412445 -678178263 997106377 -606986759 -935133962 789580574 146423403 311244165 128275576 293382425 -343236452 -129739866 297275579 -544315744 -265932257 706775276 546473875 920641717 535858699 -577233370 -920917803 -610575729 945716195 139666845 -935162943 85746982 -741600223 607422231 -566265171 -489081333 -758496475 711154361 460235728 164069616 751044523 123231423 -259609805 -72243953 -212369195 961729921 892870839 -308964931 979242434 -302663352 65648477 743566228 35334017 -828230695 947374006 289449729 512516649 301196702 -965274631 -664592617 695522363 -393140651 -360446748 658012238 -638230365 493151720 -782380639 -413…
Output: 616538530 818881821 -755072236 -39440678 243723780 243723780 489335224 123390487 123390487 489335224 818881821 818881821 997106377 145412445 145412445 997106377 997106377 999971239 789580574 789580574 920641717 311244165 706775276 293382425 297275579 -129739866 297275579 706775276 -265932257 706775276 920641717 920641717 945716195 945716195 945716195 -610575729 945716195 961729921 607422231 85746982 607422231 607422231 711154361 -489081333 711154361 711154361 751044523 751044523 751044523 961729921 961729921 -72243953 961729921 961729921 979242434 979242434 979242434 983318392 65648477 743566228 947374006 947374006 947374006 953724540 512516649 695522363 695522363 -664592617 695522363 844930381 -360446748 658012238 844930381 493151720 501212746 -413723326 -313412585 -313412585 -174740892 -…

Example 2:

Input: 2035 611891844 -904017078 56287070 549384482 -977546681 184962887 234202342 202007936 -2699539 579073153 918593413 323517183 -537874612 -70108750 571672113 900190450 533441760 984626588 957427259 -560982111 105810340 277937219 884110357 974896823 313565587 -957963723 777114190 -375431142 673265564 465193081 -307680477 -609589689 898048214 -247642478 -427532302 325043695 502021642 413014179 -340519960 -747256355 721764303 480113801 -814831144 -323971052 907338340 804522078 -513689514 -953032879 -493573952 -68224275 -204962884 -339298257 328580775 64396657 741361389 951837923 -684163712 -765611515 117845034 569109906 -285235707 -584903862 751973624 -371242856 -166606805 -369450141 -397237026 556539048 481674625 785896642 337252103 -82903692 912548912 487061794 -249905059 750854942 -352033717…
Output: 918593413 56287070 549384482 579073153 184962887 234202342 579073153 579073153 579073153 918593413 984626588 571672113 -70108750 571672113 900190450 984626588 984626588 998382940 974896823 105810340 277937219 884110357 974896823 998382940 777114190 777114190 898048214 673265564 898048214 898048214 898048214 898048214 907338340 325043695 325043695 502021642 721764303 721764303 721764303 721764303 907338340 907338340 -323971052 907338340 951837923 951837923 -493573952 -493573952 -68224275 328580775 328580775 328580775 741361389 741361389 951837923 963496879 117845034 117845034 569109906 751973624 751973624 751973624 785896642 -166606805 556539048 556539048 556539048 785896642 785896642 912548912 912548912 912548912 963496879 750854942 750854942 963496879 -53028982 337840556 -111007637 337840…

Example 3:

Input: 3327 85024351 940470652 386322728 376328740 -295327271 583161716 777710949 -340331599 -396825516 -799854238 117497806 842522740 249453775 -591837018 -805213639 257148669 -564566616 -47247686 -890088945 737198524 925005933 102954350 -715761364 104279271 442088115 386348260 -212363559 174926357 -549819381 100706511 -168250710 410869649 -559251035 -50048274 -487796253 -339328067 80475395 930797658 637497174 -366362045 -590976108 -724790523 988387615 399901618 786425196 385828502 561004437 695517760 16744691 660534045 -399803050 591930746 467745565 -623591423 334492404 -77004489 -964555991 -879399399 65244800 815617593 873574760 118357112 -485192601 605222523 -843425892 656328038 -613363753 396726007 -830110873 186799989 748234711 954436429 -803690178 787963506 868758390 -887592570 782214470 -…
Output: 940470652 988387615 583161716 583161716 583161716 777710949 842522740 117497806 117497806 117497806 842522740 925005933 257148669 257148669 257148669 737198524 -47247686 737198524 737198524 925005933 930797658 104279271 104279271 442088115 930797658 410869649 174926357 410869649 100706511 410869649 410869649 930797658 -50048274 80475395 -339328067 80475395 930797658 988387615 988387615 988387615 988387615 988387615 988730860 786425196 815617593 561004437 695517760 815617593 660534045 815617593 591930746 815617593 815617593 334492404 815617593 65244800 -879399399 65244800 815617593 873574760 954436429 605222523 605222523 656328038 656328038 748234711 396726007 748234711 186799989 748234711 954436429 979008820 787963506 868758390 890754702 782214470 890754702 299986651 403028890 741735214 77…

Constraints:

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

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