CT47838

The Taller Ahead at Rushing Falls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the salmon ladder of Rushing Falls close for winter, Forester must finish the marks ledger - one figure at a time. 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: 356 837507856 -242675802 802864108 127551154 -1526715 -816989628 472645168 -470743801 496715191 273735999 149465990 192480304 -157920512 -503151101 384606144 -959234803 -834999807 195310886 -446770143 -837932833 172709585 -264473178 487087284 -939758589 654926625 712656313 -935567994 -809325372 -186999689 -341060481 257660349 747966422 -756195978 -883153142 -61099710 -546741904 -854410399 926585806 486576197 -804853861 -667797483 -132731871 71811762 888778734 -809596095 -70227523 2751654 -149328780 -662373404 -438912052 956174097 788821519 459714552 -253406151 706024271 -685860982 -154362224 -794511957 -192866255 404765397 115104453 -22360049 -886580914 -173532398 550145681 334126193 442201919 601789653 -349941614 365476937 571649429 48179364 224449220 -16843019 -850899781 -234112974 -5396…
Output: 926585806 802864108 926585806 472645168 472645168 472645168 496715191 496715191 654926625 384606144 192480304 384606144 384606144 384606144 487087284 -834999807 195310886 487087284 172709585 172709585 487087284 487087284 654926625 654926625 712656313 747966422 -809325372 -186999689 257660349 257660349 747966422 926585806 -61099710 -61099710 926585806 926585806 926585806 956174097 888778734 -667797483 -132731871 71811762 888778734 956174097 -70227523 2751654 956174097 956174097 -438912052 956174097 972204351 940586941 706024271 706024271 940586941 -154362224 404765397 -192866255 404765397 550145681 550145681 550145681 -173532398 550145681 601789653 442201919 601789653 622857119 365476937 571649429 622857119 224449220 347612194 347612194 -234112974 -75564536 -270725748 -270725748 -75564536 3…

Example 2:

Input: 3198 -892277531 866426904 -889861878 612601540 -192071297 -282619554 229800502 314198113 -819868186 200396295 -182654475 -744715534 932722789 952091378 329891962 527570375 50717235 707558196 513479062 -174731697 -547389877 493135820 10483254 318178773 -688678405 -396323035 -406645328 836103675 989891539 847073341 -868348055 770469344 259007328 514989764 -531731920 -704480622 -83343644 698677601 742108625 -714059096 752247581 88780225 -814517493 268280691 730597158 -58241774 -125800841 956232161 -976190373 -627305195 462924134 -862499468 -859845810 -451389537 -821458588 922014189 -446154021 -779852885 737489058 -300273564 -519784437 359353578 -275006479 -992356001 142822221 -963304619 -480332486 419044269 173191861 642047893 -589530808 -10600540 156108593 16475891 466413520 527829360 -84849…
Output: 866426904 932722789 612601540 932722789 229800502 229800502 314198113 932722789 200396295 932722789 932722789 932722789 952091378 989891539 527570375 707558196 707558196 836103675 836103675 493135820 493135820 836103675 318178773 836103675 -396323035 836103675 836103675 989891539 996288388 956232161 770469344 956232161 514989764 698677601 -83343644 -83343644 698677601 742108625 752247581 752247581 956232161 268280691 268280691 730597158 956232161 956232161 956232161 988620525 -627305195 462924134 922014189 -859845810 -451389537 922014189 922014189 988620525 737489058 737489058 988620525 359353578 359353578 419044269 142822221 142822221 419044269 -480332486 419044269 642047893 642047893 988620525 -10600540 156108593 466413520 466413520 527829360 988620525 249230884 249230884 988620525 98862…

Example 3:

Input: 286 829953473 675309552 597868137 494014172 89012145 659726636 678853213 552275948 -132705907 -828377151 88167475 571911106 -64756403 249650850 473053280 -671446770 -225335973 -535965465 -419572973 -547808881 737627685 620663425 -175687538 516185545 105341123 -120678452 -146160049 -819628644 -128797103 -519559438 -545204693 786373759 116990876 -326313439 -55941917 -429964646 583706747 648563375 -255820445 695843135 -445020878 912447524 690240533 -408339740 -991844265 -63107754 -235556411 799147278 -673875300 765877282 -419760343 71513301 -961107252 176081360 -831374245 219694719 -17477165 -945656138 785974527 590376896 -977436247 520161919 -993678559 17741753 986777539 -677828079 206259728 -984052775 428274178 366001470 -978712093 -71229859 -739114820 -68928223 742543283 313589973 17975834…
Output: 912447524 678853213 659726636 659726636 659726636 678853213 737627685 571911106 88167475 88167475 571911106 737627685 249650850 473053280 737627685 -225335973 737627685 -419572973 737627685 737627685 786373759 786373759 516185545 786373759 786373759 786373759 -128797103 -128797103 786373759 786373759 786373759 912447524 583706747 -55941917 583706747 583706747 648563375 695843135 695843135 912447524 912447524 986777539 799147278 -63107754 -63107754 799147278 799147278 986777539 765877282 785974527 71513301 176081360 176081360 219694719 219694719 785974527 785974527 785974527 986777539 986777539 520161919 986777539 17741753 986777539 987443835 206259728 428274178 428274178 742543283 742543283 -71229859 -68928223 -68928223 742543283 975935980 558446882 558446882 53960429 53960429 558446882 56…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Taller Ahead at Rushing Falls - MEDIUM Coding Problem | CodeTikki