CT37504

Wren's Taller Ahead Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Wren found an old ledger of marks in the foundry attic at the honeycomb cliffs of Beeswick. 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: 1221 -701778147 -575492548 -799035523 -877318578 -763858530 929925275 993550425 -141885388 -783218967 716206251 -694774931 -10540112 -596561971 -557288699 129797527 -820174985 336159137 -877403585 -701136518 458201379 224391816 759385707 379516642 195420504 -878869930 605315474 -973172825 -52534884 622075560 -360706843 -751178315 -220666028 995818638 -688386692 -60907132 -512253008 765948052 341423836 318745026 -998628170 -448302134 74044850 762799896 88978167 605465714 574303655 -283099158 195879674 -843181871 -419664442 198388164 -270082310 319118367 386211941 -522599812 22521739 307524857 150500088 -491843948 -371749480 526657669 155031621 306366728 284153815 278408900 583679072 -468106702 275237824 -693824337 -154824727 -870306198 745635076 239810750 149100058 -225287536 -141961620 651…
Output: -575492548 929925275 -763858530 -763858530 929925275 993550425 995818638 716206251 716206251 759385707 -10540112 129797527 -557288699 129797527 336159137 336159137 458201379 -701136518 458201379 759385707 759385707 995818638 605315474 605315474 605315474 622075560 -52534884 622075560 995818638 -220666028 -220666028 995818638 998961390 -60907132 765948052 765948052 889114112 762799896 762799896 -448302134 74044850 762799896 889114112 605465714 745635076 583679072 195879674 198388164 -419664442 198388164 319118367 319118367 386211941 526657669 22521739 307524857 526657669 526657669 -371749480 526657669 583679072 306366728 583679072 583679072 583679072 745635076 275237824 745635076 -154824727 745635076 745635076 889114112 651881722 651881722 -141961620 651881722 889114112 -502098947 -19547069…

Example 2:

Input: 2833 417131393 115226691 -14361884 773822510 820057276 -364503073 -192626695 -366642947 803937393 276404114 -852151207 -602811362 57537900 608671775 970182078 -253479800 754125191 -20562892 -295281676 -196784240 170658469 488107007 116442309 346297285 -522471548 146286188 -750179163 204193762 599548563 150257251 175606682 391259109 564204572 866831351 -950169116 -151682410 -7656545 -726205094 -75275053 -318138344 264011350 -801197782 330539287 678885886 -98687191 -819121032 382416837 621268121 -642498711 194061408 -754296425 -888786076 -712684716 -631119063 -791726602 422417974 390140504 45691811 681215198 -633185000 -820824858 -268986380 -294287145 -64021233 -239352322 -636855322 -506375114 -26220185 -524544859 -770618808 571553030 -793028069 568905569 2765816 236992095 500177300 -1691857…
Output: 773822510 773822510 773822510 820057276 970182078 -192626695 803937393 803937393 970182078 608671775 -602811362 57537900 608671775 970182078 985156387 754125191 866831351 170658469 -196784240 170658469 488107007 599548563 346297285 599548563 146286188 204193762 204193762 599548563 866831351 175606682 391259109 564204572 866831351 985156387 -151682410 -7656545 264011350 -75275053 264011350 264011350 330539287 330539287 678885886 681215198 382416837 382416837 621268121 681215198 194061408 422417974 -712684716 -712684716 -631119063 422417974 422417974 681215198 681215198 681215198 985156387 -268986380 -268986380 -64021233 -64021233 -26220185 -26220185 -506375114 -26220185 571553030 571553030 571553030 676973065 568905569 676973065 236992095 500177300 676973065 -88941341 -478192266 -88941341 6…

Example 3:

Input: 3168 -257207736 -50297773 646124211 -363547071 -255129195 -136733166 -288106335 -423684962 271631363 -409242827 209718627 -741570152 992312328 -486870837 -79872864 -987324339 -210342999 883314940 273628926 -989491946 -117043547 -577618605 -661151092 487661529 419446682 267090740 860069086 725233801 -590808910 225181252 690658313 -96701320 -692128883 185694954 -935309008 640800599 975628261 -467601514 418272164 -133439320 788909428 -731917311 -509137736 -482565181 -179328381 577347926 -985240765 -337666951 -610341117 -628175016 -363632416 189408852 -233136722 -816699281 -802158291 -252650267 173762218 926385130 926767256 976920701 -985487189 506728981 846075487 -562958473 -637004433 788744810 402483769 198375215 -779848955 781390632 -41313174 -391956799 719182208 -917010955 141689861 -34438…
Output: -50297773 646124211 992312328 -255129195 -136733166 271631363 271631363 271631363 992312328 209718627 992312328 992312328 998928732 -79872864 883314940 -210342999 883314940 975628261 487661529 -117043547 487661529 487661529 487661529 860069086 860069086 860069086 975628261 975628261 225181252 690658313 975628261 185694954 185694954 640800599 640800599 975628261 976920701 418272164 788909428 788909428 926385130 -509137736 -482565181 -179328381 577347926 926385130 -337666951 189408852 -363632416 -363632416 189408852 926385130 173762218 -802158291 -252650267 173762218 926385130 926767256 976920701 989479788 506728981 846075487 914078133 788744810 788744810 914078133 781390632 781390632 781390632 914078133 719182208 719182208 771706119 141689861 291842180 291842180 438786110 438786110 43878611…

Constraints:

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

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