CT56772

Elsa and the Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the floating docks of Skyharbor, Elsa records each registers 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: 691 700426016 -716983709 96589039 639711454 766578496 452476047 198018475 -488381780 922937221 -95993932 -790268761 -569197242 -6356679 896564646 -444203566 770056312 -614448558 179336537 520826738 -357753714 4662565 108354441 -388091394 -239899739 -669444988 -61580335 -508069039 853349404 775989328 -440924123 -366981172 -47655066 203863865 710451587 586914631 -789938292 -996655472 -951239402 -339965849 500581106 942902504 -667118833 220235328 720864802 557762364 -517218780 -943402277 -930690803 -945180020 -357072570 -456897168 30944771 879878791 405469258 289691667 -700003407 908296171 -502898192 -540255748 -62526936 525299416 526821345 -481394612 -472145986 -648851246 890128384 85292456 780358444 -52298637 -874716854 -668390382 -94132494 914736979 -374480137 472185072 -342358628 -2048197…
Output: 766578496 96589039 639711454 766578496 922937221 922937221 922937221 922937221 942902504 -6356679 -569197242 -6356679 896564646 942902504 770056312 853349404 179336537 520826738 853349404 4662565 108354441 853349404 -239899739 -61580335 -61580335 853349404 853349404 942902504 942902504 -366981172 -47655066 203863865 710451587 942902504 942902504 -339965849 -951239402 -339965849 500581106 942902504 996380372 220235328 720864802 879878791 879878791 -357072570 -930690803 -357072570 -357072570 30944771 30944771 879878791 908296171 908296171 908296171 908296171 914736979 -62526936 -62526936 525299416 526821345 890128384 -472145986 890128384 890128384 914736979 780358444 914736979 914736979 -668390382 -94132494 914736979 996380372 472185072 996380372 -204819786 996380372 996380372 996380372 -1 7…

Example 2:

Input: 1606 -577589724 -324184256 958560716 -849734795 -25768044 -106544013 -992990709 -783903713 -346010047 845832151 -428579876 76708008 -683899803 -743968269 -520855329 -76742438 -595997612 520674872 -48365717 369853511 65849608 313092282 -964925330 -284295241 805781861 202831122 -211157167 -469224669 625909335 -528971912 353483738 231997804 -909562539 -91045825 -935196639 -33324547 964919764 214453018 438517166 161158496 841900223 -167604515 -727380056 364231557 -48670419 -468514412 -965462553 -132324097 -657699892 309278677 -551693334 179796447 958074026 730179793 -543530765 -19464126 741899739 -563126042 -164902443 990413033 -23052956 -655658669 770236528 -247843503 -603398401 -99890855 482068704 778645519 176741569 76125002 -710329344 157043188 -601743099 -261802932 977551703 -734615703 -1…
Output: -324184256 958560716 964919764 -25768044 845832151 845832151 -783903713 -346010047 845832151 964919764 76708008 520674872 -520855329 -520855329 -76742438 520674872 520674872 805781861 369853511 805781861 313092282 805781861 -284295241 805781861 964919764 625909335 625909335 625909335 964919764 353483738 964919764 964919764 -91045825 -33324547 -33324547 964919764 990413033 438517166 841900223 841900223 958074026 364231557 364231557 958074026 309278677 -132324097 -132324097 309278677 309278677 958074026 179796447 958074026 990413033 741899739 -19464126 741899739 990413033 -164902443 990413033 993059292 770236528 770236528 778645519 -99890855 -99890855 482068704 778645519 977551703 977551703 157043188 157043188 977551703 -261802932 977551703 993059292 -154488472 502232080 859654263 48076433 8…

Example 3:

Input: 3017 -445229220 -898186973 -824589673 -282314130 -646256728 518029483 -646935753 885510900 -98267638 254126110 -731980283 -468263852 73345301 377601252 -84467582 -847461890 598447137 669776456 750117991 79817268 881856111 -656134641 378391310 726831579 584258794 189852712 -901161961 -318964893 -502627863 -486465534 582720831 634627703 577654210 137808235 280844297 459280711 243218355 -191494503 817599628 778797546 114893347 -284134108 -566229549 -256652585 695610154 -541020027 -24991901 -462153945 -140376795 747239669 192830771 471296590 344267764 415272570 564032097 185428782 -15925126 -536451979 -779649386 -655100005 -261002499 957377440 -766057807 691650420 -493109820 -794112537 6789428 -846708509 -105436495 -466693549 875585536 345749551 925706122 -479610533 776391312 830562605 -191437…
Output: -282314130 -824589673 -282314130 518029483 518029483 885510900 885510900 957377440 254126110 377601252 -468263852 73345301 377601252 598447137 598447137 598447137 669776456 750117991 881856111 881856111 957377440 378391310 726831579 817599628 634627703 582720831 -318964893 582720831 -486465534 582720831 634627703 817599628 817599628 280844297 459280711 817599628 817599628 817599628 957377440 957377440 695610154 -256652585 -256652585 695610154 747239669 -24991901 747239669 -140376795 747239669 957377440 471296590 564032097 415272570 564032097 957377440 957377440 957377440 -261002499 -655100005 -261002499 957377440 998147642 691650420 875585536 6789428 6789428 875585536 -105436495 875585536 875585536 925706122 925706122 954479124 776391312 830562605 954479124 622097380 622097380 699949167 95…

Constraints:

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

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