CT37172

Jade beacons Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the mountain city of Highreach, Zephyr records each beacons 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: 1611 844660756 484144591 442540929 -654640422 443576064 412719308 -756908402 289023136 -924498278 -423667838 908683187 188527124 -125543726 141743726 639655956 933279147 167255637 483947901 -253743315 820368538 -51487325 560518702 546386490 551841491 419340622 687497802 879967811 32757884 837108755 -122010615 88050916 424330223 -369864016 675402500 -336248548 854091991 -643187749 -448997162 606124583 -958979967 7474720 499131732 704083513 152972524 44038265 513939371 -281977032 -790760428 -657352210 980967464 825004219 119653525 941686044 -190040597 142867398 66048566 -406487727 -111549606 557785168 656283038 -396667454 120630406 432008295 332938672 -816739920 -265708973 -565189628 359762888 915592577 85553212 150194164 -790623755 274203525 374434308 955444988 796675590 722362948 -9784545 …
Output: 908683187 908683187 443576064 443576064 908683187 908683187 289023136 908683187 -423667838 908683187 933279147 639655956 141743726 639655956 933279147 980967464 483947901 820368538 820368538 879967811 560518702 687497802 551841491 687497802 687497802 879967811 980967464 837108755 854091991 88050916 424330223 675402500 675402500 854091991 854091991 980967464 -448997162 606124583 704083513 7474720 499131732 704083513 980967464 513939371 513939371 980967464 980967464 -657352210 980967464 992316013 941686044 941686044 955444988 142867398 557785168 557785168 -111549606 557785168 656283038 915592577 120630406 432008295 915592577 359762888 -265708973 359762888 359762888 915592577 955444988 150194164 274203525 274203525 374434308 955444988 960310682 946547181 946547181 520816159 520816159 53366304…

Example 2:

Input: 3407 855651756 389066280 724850017 554124762 410339813 -338571123 383122637 -426575693 -223186589 961704534 562288211 65629189 -232913000 906170378 -671340770 232008882 465411379 470830730 -363003652 -287364417 -309267513 -382052542 -666635162 -875937230 -605372636 -723730445 133291034 -536352621 -254468352 -27777127 -105983318 652085545 -728567615 330795502 581943932 -715630007 -715958056 -934665355 -248729073 846885352 346828680 -781765830 -641424215 -323941435 -73936463 -298987428 460937938 755002321 521294246 -117569391 -446056604 768379336 -793034434 -496879525 -686640797 -648569305 638110379 -896217956 -428741544 -57515815 286259840 199734059 450417990 -708840103 -424204735 -535673460 752560793 -57221740 -909540596 548833675 114664238 321685987 68089972 86901831 602748541 -971032010 …
Output: 961704534 724850017 961704534 961704534 961704534 383122637 961704534 -223186589 961704534 993131033 906170378 906170378 906170378 920332450 232008882 465411379 470830730 652085545 -287364417 133291034 133291034 133291034 -605372636 -605372636 133291034 133291034 652085545 -254468352 -27777127 652085545 652085545 846885352 330795502 581943932 846885352 -248729073 -248729073 -248729073 846885352 885142965 460937938 -641424215 -323941435 -73936463 460937938 460937938 755002321 768379336 768379336 768379336 768379336 885142965 -496879525 638110379 -648569305 638110379 752560793 -428741544 -57515815 286259840 450417990 450417990 752560793 -424204735 752560793 752560793 885142965 548833675 548833675 602748541 321685987 602748541 86901831 602748541 885142965 885142965 920332450 920332450 2138474…

Example 3:

Input: 2539 937091059 -768708040 666531460 -371816741 526605026 -990072727 790072217 -278928007 136915191 18476624 -119858068 -381533979 -597284790 -13046937 -725807217 791630591 -908908786 -265031855 459374774 -701478794 599618566 140388470 -949329781 -229644711 -76418411 -685383806 -191029091 -83465295 -718017630 566919766 -619780639 976372571 372932658 511046885 -621830769 -676741611 -129461559 210671895 -764394610 551910289 835822601 580312994 -654694560 -751598349 632078806 302646331 510985314 701507700 55944167 351236115 -495438925 -434856956 -366984361 868458855 641186906 -649340134 -193358942 175425227 984291421 78806893 621471072 -554286061 -499880727 785655764 677820163 -126158915 561398389 -4929130 613327285 -507022196 -535468038 797663296 98557151 -847198392 -821097882 -31372369 -8568…
Output: 976372571 666531460 790072217 526605026 790072217 790072217 791630591 136915191 791630591 791630591 -13046937 -13046937 -13046937 791630591 791630591 976372571 -265031855 459374774 599618566 599618566 976372571 566919766 -229644711 -76418411 566919766 -191029091 -83465295 566919766 566919766 976372571 976372571 984291421 511046885 551910289 -129461559 -129461559 210671895 551910289 551910289 835822601 868458855 632078806 632078806 632078806 701507700 510985314 701507700 868458855 351236115 868458855 -434856956 -366984361 868458855 984291421 984291421 -193358942 175425227 984291421 984356832 621471072 785655764 -499880727 785655764 797663296 797663296 561398389 613327285 613327285 797663296 797663296 797663296 961574314 265852091 -821097882 -31372369 265852091 265852091 535169378 65166501 6…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jade beacons Taller Ahead - MEDIUM Coding Problem | CodeTikki