CT47362

Gautam and the Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the quays of Driftwood pays by the answer, and Gautam intends to earn it. First: the full register of beacons. 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: 1678 760843078 28335233 602777585 -575828626 -354350837 790588259 -352025231 -719435917 -585642181 675791530 -79954386 -106853484 432333835 -536372380 -266824509 666452326 -113258812 130171830 -688097884 -816013402 44988772 -496562748 -657973019 -568924639 -451355361 137352331 -134892684 -174591656 340394244 -412157299 -266699292 451052512 200760027 774930644 -382212236 448121741 387786348 613597003 958290053 -592407437 513348477 655899454 -216614725 -541082134 867781801 -247496957 -17297888 253844432 -187528294 418142552 569937901 815986119 -961873242 -873334821 -852559593 -110479484 -498571305 385114645 124094898 -99885897 48963239 -533394282 -46880747 554056067 -991499159 181740273 842927339 -802201630 321422245 929826241 -557792754 -514918354 992248496 521863961 -646774233 -658259947 -…
Output: 790588259 602777585 790588259 -354350837 790588259 958290053 675791530 -585642181 675791530 774930644 432333835 432333835 666452326 -266824509 666452326 774930644 130171830 137352331 44988772 44988772 137352331 -451355361 -568924639 -451355361 137352331 340394244 340394244 340394244 451052512 -266699292 451052512 774930644 774930644 958290053 448121741 613597003 613597003 958290053 992248496 513348477 655899454 867781801 867781801 867781801 929826241 -17297888 253844432 418142552 418142552 569937901 815986119 842927339 -873334821 -852559593 -110479484 385114645 385114645 554056067 554056067 48963239 554056067 -46880747 554056067 842927339 181740273 842927339 929826241 321422245 929826241 992248496 -514918354 992248496 998628613 957764685 -563502861 -563502861 513276550 957764685 355451635 …

Example 2:

Input: 2995 953988380 448740615 350645938 891322933 152466831 -591118771 -809773396 -25424407 -422599230 777753653 54771342 -290290886 408560279 -646509665 -642672717 122207721 -40498076 -880195036 -143740613 -497493081 697219574 -52821447 94260141 155373729 -81691849 776047007 131849386 783345630 -904611268 -730418673 -160693190 -162372227 -568526458 243596446 -23369227 797372552 389301122 -550933335 5136699 -299244568 810449835 -408030253 -65644017 -55940969 736225328 27487986 52851600 -359335087 -105762123 382213370 -328272739 -194942961 494202242 -332985687 801692896 -896231802 -328472038 -944545983 -223030156 756270044 -556420383 54045460 -54339496 61712080 -501061851 -992633001 35132767 -941168764 906807197 -608373146 755355492 213134162 -50522189 -557883479 778779914 311373670 334625166 -5…
Output: 991825464 891322933 891322933 906807197 777753653 -25424407 -25424407 777753653 777753653 783345630 408560279 408560279 697219574 -642672717 122207721 697219574 697219574 -143740613 697219574 697219574 776047007 94260141 155373729 776047007 776047007 783345630 783345630 797372552 -730418673 -160693190 243596446 243596446 243596446 797372552 797372552 810449835 810449835 5136699 810449835 810449835 906807197 -65644017 -55940969 736225328 801692896 52851600 382213370 -105762123 382213370 494202242 -194942961 494202242 801692896 801692896 906807197 -328472038 -223030156 -223030156 756270044 906807197 54045460 61712080 61712080 906807197 35132767 35132767 906807197 906807197 914483689 755355492 778779914 778779914 778779914 778779914 914483689 334625166 602940722 602940722 602940722 914483689 …

Example 3:

Input: 2536 243159124 517969279 434799949 501932912 820097371 -381598289 907809263 658939321 294098019 92614022 -215686936 318538380 206023573 158496403 -994662635 11208074 -687584580 268461316 59034399 -3879046 -112514423 745187725 29172120 -419372675 98796603 610834019 244749384 -490697347 -798621055 326031971 -792642940 -555354141 -685423351 576338012 859767185 -351329147 -318273248 -834477295 -363900289 748758873 899108089 -362816662 985800099 -360988177 626641977 608953931 920480262 -111345449 331817763 -367415037 759980626 782682749 522572650 187970798 392257322 -464031627 574222807 -487412345 94934905 443895388 229122979 644648722 27164237 -279986052 814928733 719454186 202931333 -152349413 180858470 994071221 659103337 -787130322 874896377 -785308471 707549419 -237155524 -252942958 852403…
Output: 517969279 820097371 501932912 820097371 907809263 907809263 985800099 745187725 318538380 318538380 318538380 745187725 268461316 268461316 11208074 268461316 268461316 745187725 745187725 745187725 745187725 859767185 98796603 98796603 610834019 859767185 326031971 326031971 326031971 576338012 -555354141 576338012 576338012 859767185 899108089 -318273248 748758873 -363900289 748758873 899108089 985800099 985800099 994071221 626641977 920480262 920480262 994071221 331817763 759980626 759980626 782682749 814928733 574222807 392257322 574222807 574222807 644648722 94934905 443895388 644648722 644648722 814928733 814928733 814928733 994071221 994071221 994071221 180858470 994071221 995552271 874896377 874896377 938117650 707549419 852403753 852403753 852403753 938117650 379472324 837740245 1…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Gautam and the Taller Ahead - MEDIUM Coding Problem | CodeTikki