CT45966

The beacons at Crosswater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the ferry landing of Crosswater, Sage studies rows of beacons entries. One clean number will settle the guild's oldest argument. 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: 3386 -668981196 216678383 -882003115 891463792 975464569 712583683 -887353656 619394514 -218051908 -355365802 609051135 697804964 -808533095 296488928 532131282 550419379 -243094500 296304351 472991433 -438126416 694992586 -226915380 170994150 64195189 466917400 -838617128 -402180041 -346933812 918076768 820709990 457267461 -741223350 -202972631 -408165737 929393746 -540757800 -791271849 -81829183 -320001635 44884778 712667093 -699956815 249127411 267091611 -254140935 -194227212 -437662914 287364284 -489258205 548196144 61854025 121864748 426922275 -921842299 -123186604 -375022819 -997764467 -650238077 -888534703 935996662 909812577 -307033270 -432425415 -134654532 -896491506 339353317 -883378664 -747690861 -438159634 388591070 -826486823 429227325 695812640 -60645294 -652473294 -106586981…
Output: 216678383 891463792 891463792 975464569 978365074 918076768 619394514 697804964 609051135 609051135 697804964 918076768 296488928 532131282 550419379 694992586 296304351 472991433 694992586 694992586 918076768 170994150 466917400 466917400 918076768 -402180041 -346933812 918076768 929393746 929393746 929393746 -202972631 929393746 929393746 935996662 -81829183 -81829183 44884778 44884778 712667093 935996662 249127411 267091611 287364284 -194227212 287364284 287364284 548196144 548196144 935996662 121864748 426922275 935996662 -123186604 935996662 935996662 -650238077 935996662 935996662 978365074 922138731 -134654532 -134654532 339353317 339353317 388591070 -747690861 -438159634 388591070 429227325 429227325 695812640 786496504 576891822 -106586981 576891822 576891822 786496504 873047146 9…

Example 2:

Input: 2060 -950229473 -626172369 -199405876 492337499 970773667 646015339 172706026 682485174 -864362759 52317337 219033795 -890172331 -108973610 670140969 -826600094 -753398308 194948332 242324644 -503688241 -665299014 801380746 -427496227 895502600 -958266085 -674474390 -276347318 -895294926 -49964645 390344581 -535026720 -855626539 968420945 -624021152 -509829362 622146651 340456939 90429938 414328062 -959204035 -164440018 -329216895 325538962 304601750 -424768580 945740368 875412574 -343789806 -650434819 943018001 -13533621 111780278 109789318 -879956321 -583300946 -680618609 -921944779 -739857661 160448778 -682893791 733536902 51546794 -780851 -498531452 350599573 611446195 191605292 447609250 -417997680 -620155780 -835309042 -58893391 -455292759 161484591 -922104970 375810361 944802443 -75…
Output: -626172369 -199405876 492337499 970773667 982520352 682485174 682485174 801380746 52317337 219033795 670140969 -108973610 670140969 801380746 -753398308 194948332 242324644 801380746 801380746 801380746 895502600 895502600 968420945 -674474390 -276347318 -49964645 -49964645 390344581 968420945 968420945 968420945 982520352 -509829362 622146651 945740368 414328062 414328062 945740368 -164440018 325538962 325538962 945740368 945740368 945740368 963846229 943018001 943018001 943018001 944802443 111780278 160448778 160448778 -583300946 160448778 160448778 -739857661 160448778 733536902 733536902 944802443 350599573 350599573 350599573 611446195 944802443 447609250 944802443 -58893391 -58893391 -58893391 161484591 161484591 375810361 375810361 944802443 963846229 177213879 919661916 963846229 7…

Example 3:

Input: 3220 -915565100 401076791 -365363553 331984518 904346636 857073547 428196890 129125486 628427771 548612455 504287875 -820493275 -843182733 883460600 -178440223 -498881860 -698121795 815906510 -363099672 -999141797 427494771 -80312204 -121734598 -415045232 647909764 -923590503 -585026599 899654256 -380945733 -15276012 -96862305 -501125264 656973028 579379836 -589911525 -87428086 68574936 -375497921 -160062298 809653282 -639759595 525278 735465934 272856191 -64900067 -740904566 -586459985 -690715606 -749073471 -280214809 -474439267 -718903126 -549466125 -819000564 406471665 154530340 -465319059 -355286062 860773657 857735675 -162352918 -491625572 -24990049 -255170707 -659320619 886949305 113236875 522327052 -363484343 -801320894 371067723 -570224926 792825979 657674853 957298961 -541642360 -…
Output: 401076791 904346636 331984518 904346636 957298961 883460600 628427771 628427771 883460600 883460600 883460600 883460600 883460600 899654256 815906510 815906510 815906510 899654256 427494771 427494771 647909764 647909764 647909764 647909764 899654256 -585026599 899654256 957298961 -15276012 656973028 656973028 656973028 809653282 809653282 -87428086 68574936 809653282 -160062298 809653282 860773657 525278 735465934 860773657 406471665 406471665 -586459985 -280214809 -280214809 -280214809 406471665 406471665 -549466125 406471665 406471665 860773657 860773657 -355286062 860773657 886949305 886949305 -24990049 -24990049 886949305 886949305 886949305 957298961 522327052 792825979 371067723 371067723 792825979 792825979 957298961 957298961 978702839 724409398 724409398 792267728 792267728 837410…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The beacons at Crosswater - MEDIUM Coding Problem | CodeTikki