CT56860

Porter's Scarlet beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the river town of Willowford. Porter spreads the beacons records across the table and picks up a sharp pencil. 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: 1689 674580281 748840190 605169327 -234564319 196066857 -834174470 852675 -637252670 384050298 -948796790 -304037463 583913659 -988086985 -219936203 -772618893 -594411141 395837090 -66112900 -443003236 -388122944 -112470435 291202127 945004863 34993495 -954150527 461333995 462558919 150979408 -83682100 -727374838 -101799382 168529275 783550655 192359688 190534697 -994331773 -304362247 702718345 448993888 -936596328 -402129713 -206989661 644066054 936459279 18731131 -662751601 -823399076 -714630412 -606889649 322007067 -47876339 -247776719 -727103478 728376672 997740259 154255506 -748790243 -643717995 832791322 673727062 660298812 549019139 778484338 -605610073 415024916 -610189281 -955609365 232895136 252459152 -381543977 946363713 78230517 -865339767 -876793787 944249309 -623677297 560379…
Output: 748840190 945004863 945004863 196066857 384050298 852675 384050298 384050298 583913659 -304037463 583913659 945004863 -219936203 395837090 -594411141 395837090 945004863 291202127 -388122944 -112470435 291202127 945004863 997740259 461333995 461333995 462558919 783550655 168529275 168529275 -101799382 168529275 783550655 936459279 702718345 702718345 -304362247 702718345 936459279 644066054 -402129713 -206989661 644066054 936459279 997740259 322007067 -606889649 -714630412 -606889649 322007067 728376672 728376672 728376672 728376672 997740259 998073130 832791322 -643717995 832791322 946363713 778484338 778484338 778484338 946363713 415024916 946363713 232895136 232895136 252459152 946363713 946363713 982208503 944249309 944249309 944249309 982208503 560379064 982208503 121124514 982208503 …

Example 2:

Input: 2166 758746308 124406131 -7706769 458560032 27608417 -9490178 496369653 912439924 607105512 468154921 785840300 34857713 -631253439 373501813 998111999 651101904 299300837 -602729667 593867063 -242210958 293279362 -72415663 369088004 780618771 869251249 416206577 129332974 586007549 -254117800 298929262 14153809 -778345379 -962963313 290483803 955328689 280790155 652991985 -441703457 -583304800 196024771 727876389 -681053862 8397763 -936341568 100954552 829255081 -525201972 802583247 794338914 -418035541 686599581 927058422 673813873 -412019615 -49586717 746168096 -435684572 411825548 135568002 336939350 567516049 -273963899 277159235 550418773 -192520067 -623536544 -862082013 536584960 385300302 -358087905 173354845 -152564660 751942663 -922645240 185622522 -69165904 -349704273 31491750 3…
Output: 912439924 458560032 458560032 496369653 496369653 496369653 912439924 998111999 785840300 785840300 998111999 373501813 373501813 998111999 999891382 780618771 593867063 593867063 780618771 293279362 369088004 369088004 780618771 869251249 955328689 586007549 586007549 955328689 298929262 955328689 290483803 290483803 290483803 955328689 993545429 652991985 727876389 196024771 196024771 727876389 829255081 8397763 100954552 100954552 829255081 927058422 802583247 927058422 927058422 686599581 927058422 942655240 746168096 -49586717 746168096 751942663 411825548 567516049 336939350 567516049 751942663 277159235 550418773 751942663 536584960 536584960 536584960 751942663 751942663 173354845 751942663 751942663 884575661 185622522 398873581 31491750 31491750 398873581 661709926 729693219 1728…

Example 3:

Input: 1687 -626014862 830593118 468376514 997570231 -346739331 -992046798 198748383 -775660051 -642901209 192757531 -45155799 -971452008 -45584651 557948100 561254520 -229636011 570675511 381986611 -653401274 44765739 -902447653 -420722332 710552756 99067376 71728614 -799337453 -599928499 84021558 -273375108 464279018 -787091315 -589950937 -204926066 -526832539 349983171 133842397 -992438478 -992287553 -702881328 977186980 -128784533 418079628 -815859014 -297232758 -275745159 -454281277 -249114097 957360644 656629572 -254488426 -474571425 460005059 -342874047 -969322270 -40847135 -684212191 477677447 659649056 -623006297 -589629368 -104849390 803920922 207459119 816289748 836688637 602351298 -855485709 -797461772 493182784 -748793865 -980352120 997301571 555437989 -936274386 943371274 867916924 …
Output: 830593118 997570231 997570231 998926145 198748383 198748383 557948100 -642901209 192757531 557948100 557948100 -45584651 557948100 561254520 570675511 570675511 710552756 710552756 44765739 710552756 -420722332 710552756 977186980 464279018 84021558 -599928499 84021558 464279018 464279018 977186980 -589950937 -204926066 349983171 349983171 977186980 977186980 -992287553 -702881328 977186980 997301571 418079628 957360644 -297232758 -275745159 -249114097 -249114097 957360644 997301571 659649056 460005059 460005059 477677447 -40847135 -40847135 477677447 477677447 659649056 803920922 -589629368 -104849390 803920922 816289748 816289748 836688637 997301571 997301571 -797461772 493182784 997301571 997301571 997301571 998926145 943371274 943371274 988590332 988590332 994490460 184081480 921550267…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Porter's Scarlet beacons - MEDIUM Coding Problem | CodeTikki