CT47986

The Taller Ahead Beneath Buzzwell

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Cora the log keeper watches over the honey farms of Buzzwell's stores of marks. A careful computation stands between order and chaos. 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: 2327 529124901 165560327 -438876703 -447159647 116859573 -988942763 -966421169 -247844780 -147276247 -205156736 -294703143 -454102692 524153975 943892952 -208906539 -583862811 -219614459 719572280 -713241418 -160837363 -103174575 -661424713 -743120802 -355179483 909648925 373024037 -425016965 -738519925 78429952 963493381 -335851198 416911026 520732193 750706018 -265547287 150561690 153532907 794961197 -666819493 345089077 -67314491 -639025744 -922004265 -384116255 -358688352 -153261763 -813402432 -74875483 -791149903 575493818 -746786044 -819836872 184721717 -743064606 351635665 -72112170 631105724 -548158680 -581089727 382468165 -695258126 444292174 693753632 -278062253 -240330103 -577265577 -693056833 -2895186 -662021218 964459189 -998487212 652618203 -479783409 -516454684 953306940 -14…
Output: 943892952 524153975 116859573 116859573 524153975 -966421169 -247844780 -147276247 524153975 524153975 524153975 524153975 943892952 963493381 719572280 -219614459 719572280 909648925 -160837363 -103174575 909648925 -355179483 -355179483 909648925 963493381 963493381 78429952 78429952 963493381 964459189 416911026 520732193 750706018 794961197 150561690 153532907 794961197 964459189 345089077 575493818 575493818 -384116255 -384116255 -358688352 -153261763 -74875483 -74875483 575493818 575493818 631105724 184721717 184721717 351635665 351635665 631105724 631105724 693753632 382468165 382468165 444292174 444292174 693753632 964459189 -240330103 -2895186 -2895186 -2895186 964459189 964459189 968414706 652618203 953306940 953306940 953306940 955769378 942808327 942808327 955769378 673670166 81…

Example 2:

Input: 1521 -258940033 251495630 386753761 -490622009 -909332818 27423137 -776692394 -725604117 61557826 -590352556 249658677 -179682405 337590666 -862155259 296606029 -739953895 397390978 555227351 289289733 662698178 -611098719 723390325 585741306 894919249 -734584352 695988923 596537594 -948618935 476306280 532008072 -918564590 -732447716 -196835415 -653893744 -38790784 981338721 682487464 -852567086 438212631 641586016 -25823526 972884568 -357435393 771441510 -594353587 891427158 -972598953 -184325378 -253520200 -763256779 735162160 -59639456 -659357776 -737001810 540455128 -72969980 -686244308 189592878 -335789315 126044093 -313594738 -792998392 316240737 -447403275 675164224 -119314025 -819525720 760173632 -139849788 -113756071 -95506733 604689123 -505770247 791271173 -872165508 831466243 -…
Output: 251495630 386753761 397390978 27423137 27423137 61557826 -725604117 61557826 249658677 249658677 337590666 337590666 397390978 296606029 397390978 397390978 555227351 662698178 662698178 723390325 723390325 894919249 894919249 981338721 695988923 981338721 981338721 476306280 532008072 981338721 -732447716 -196835415 -38790784 -38790784 981338721 995423973 972884568 438212631 641586016 972884568 972884568 976891190 771441510 891427158 891427158 939885333 -184325378 735162160 735162160 735162160 760173632 540455128 540455128 540455128 675164224 189592878 189592878 316240737 126044093 316240737 316240737 316240737 675164224 675164224 760173632 760173632 760173632 791271173 -113756071 -95506733 604689123 791271173 791271173 831466243 831466243 939885333 804005065 939885333 627207592 -36595754…

Example 3:

Input: 3867 365172568 -279956218 93515195 -654151370 571683227 543916900 496405456 16528306 -471391396 -176987423 509394159 -174817764 823316103 -626724570 -325369129 -751261507 678469888 -420707122 -33931228 -314831242 -426211496 519261205 -227757003 999422994 66440577 579923175 940606523 -636691263 -205187013 564500511 -61697495 -616376416 -47803500 -927683826 -674687874 -4558821 -347335829 76339611 -487717027 -562041362 832921881 675044180 -561517825 707432192 -570124067 960779276 -936404465 420799970 861130240 -439563900 601674441 -762302685 -315517932 -981452720 -583837766 -760113744 -732854497 337770951 137240726 -948790685 -874299581 -124908910 421302956 -567847455 -895864862 337208053 -904435903 524286473 -127202362 -3875680 293701467 -770825151 -952951717 117228191 460339852 -319718651 8…
Output: 571683227 93515195 571683227 571683227 823316103 823316103 509394159 509394159 -176987423 509394159 823316103 823316103 999422994 -325369129 678469888 678469888 999422994 -33931228 519261205 519261205 519261205 999422994 999422994 999816384 579923175 940606523 960779276 -205187013 564500511 832921881 -47803500 -47803500 -4558821 -674687874 -4558821 76339611 76339611 832921881 832921881 832921881 960779276 707432192 707432192 960779276 960779276 987221883 420799970 861130240 987221883 601674441 802863663 -315517932 337770951 -583837766 337770951 -732854497 337770951 421302956 421302956 -874299581 -124908910 421302956 524286473 337208053 337208053 524286473 524286473 802863663 -3875680 293701467 460339852 117228191 117228191 460339852 802863663 802863663 987221883 989960656 280196366 8967808…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Taller Ahead Beneath Buzzwell - MEDIUM Coding Problem | CodeTikki