CT45664

The Taller Ahead at Shimmerdeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the opal reefs of Shimmerdeep, Orin records each beacons in a worn leather ledger. The guild wants answers, not guesses. 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: 3067 -440912859 478294692 940763917 -647673553 -628387156 884315283 135437491 454130924 261872093 707283306 -341258350 -175100147 -544039804 133800799 -135807794 190129901 -382669040 -191058739 664437060 66503968 -661086679 -431678879 681971035 -684646310 -229375945 -744593358 702944786 -479402915 779221585 -339859606 657311361 -670766827 -217149982 -879287117 593720205 -228071170 -743093832 -169328763 -534551509 346603161 -409407103 -510408814 347098817 -177283348 354845450 428843306 28109386 414137526 -748168456 427341201 -635722898 -649128343 131548993 -497212544 -894065998 -419075230 253030390 767118479 -160898637 353293672 -500066513 -924997997 -196271059 -774993300 460420133 708128291 511332876 -220478153 927048966 104189879 466335842 -752329928 -711292760 978846487 67646868 62869140…
Output: 478294692 940763917 978846487 -628387156 884315283 927048966 454130924 707283306 707283306 779221585 -175100147 133800799 133800799 190129901 190129901 664437060 -191058739 664437060 681971035 681971035 -431678879 681971035 702944786 -229375945 702944786 702944786 779221585 779221585 927048966 657311361 767118479 -217149982 593720205 593720205 767118479 -169328763 -169328763 346603161 346603161 347098817 347098817 347098817 354845450 354845450 428843306 767118479 414137526 427341201 427341201 767118479 131548993 131548993 253030390 -419075230 -419075230 253030390 767118479 927048966 353293672 460420133 -196271059 -196271059 460420133 460420133 708128291 927048966 927048966 927048966 978846487 466335842 978846487 -711292760 978846487 982287673 336121075 336121075 -243035521 336121075 365598…

Example 2:

Input: 2316 -396519708 -773474122 623570909 -248145877 -539833734 -490171707 -581633132 -781992744 -782362584 160797880 314779490 -215937715 355166615 -774334422 236855829 -651761403 -414211577 728917529 -700168374 -183493615 900580819 -207097618 -887731915 124811836 289081419 580009608 396274916 204427532 -996801629 33327131 66999866 904948712 815915625 -425815251 -42049540 162707257 -437455405 -313262145 521376569 52155058 -474163007 735222501 734793429 889585064 523171693 -734431071 -17683577 570141410 992697832 -877944807 756483314 815661994 996613304 -869888136 826199079 -518671421 -594454542 -528044986 -584273620 -899414737 512310379 -534396346 -170949468 -170281911 495314829 770142818 -534959788 -128058796 840351258 -640497005 770546090 -540312943 354363861 -136182721 265052680 262385599 -…
Output: 623570909 623570909 728917529 160797880 -490171707 160797880 160797880 160797880 160797880 314779490 355166615 355166615 728917529 236855829 728917529 -414211577 728917529 900580819 -183493615 900580819 904948712 124811836 124811836 289081419 580009608 904948712 904948712 904948712 33327131 66999866 904948712 992697832 889585064 -42049540 162707257 521376569 -313262145 521376569 735222501 735222501 735222501 889585064 889585064 992697832 570141410 -17683577 570141410 992697832 996613304 756483314 815661994 996613304 997763853 826199079 840351258 512310379 -528044986 512310379 512310379 512310379 770142818 -170949468 -170281911 495314829 770142818 840351258 -128058796 840351258 914691727 770546090 914691727 354363861 914691727 265052680 914691727 914691727 914691727 955792083 955792083 6952…

Example 3:

Input: 1475 704808869 842738105 -223257666 838465858 928595095 -355613353 -371618179 209349354 -293250804 -428549295 583291071 -578803934 -789690341 -204939688 629587569 -314275606 71826540 -946459843 -613389784 -537239364 614623055 441988799 -445782278 -661751879 -849277002 317913132 -593605734 596011603 743186514 -448853520 -580820687 214287907 859216042 -382107407 -563138732 -105009207 293682372 -999776728 -433001077 634582821 98534531 -634531738 -623620732 -317399086 553443877 -248468290 -385513287 644968995 204774887 827063855 15256908 -520129319 764612399 -134273971 19518136 509914160 -552659564 513653214 137590667 654782601 -508464676 411440076 210739370 -589229737 -657537713 564575828 404564956 -398979888 -555053004 979895661 382542174 387971145 -14501943 340985793 -570121334 -552290163 8…
Output: 842738105 928595095 838465858 928595095 979895661 209349354 209349354 583291071 583291071 583291071 629587569 -204939688 -204939688 629587569 743186514 71826540 614623055 -613389784 -537239364 614623055 743186514 596011603 317913132 317913132 317913132 596011603 596011603 743186514 859216042 214287907 214287907 859216042 979895661 -105009207 -105009207 293682372 634582821 -433001077 634582821 644968995 553443877 -623620732 -317399086 553443877 644968995 644968995 644968995 827063855 827063855 979895661 764612399 764612399 979895661 19518136 509914160 513653214 513653214 654782601 654782601 979895661 411440076 564575828 564575828 564575828 564575828 979895661 979895661 979895661 979895661 993894720 387971145 851698524 340985793 851698524 -552290163 851698524 861504529 61015684 631642689 -20…

Constraints:

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

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