CT58240

The ledgers at Greyfen

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the foggy moor of Greyfen; Yara weighs the day's ledgers manifests and starts the calculations. Task: For every contiguous window of length k, print the maximum. Input format: First line: n and k. Second line: n integers. Output format: Print n-k+1 maxima space-separated. Constraints: 1 <= k <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 1651 793 -97585042 -104584815 452431277 650190143 -609570098 -608648475 915983517 199548096 -438215344 -692306170 -937877909 469292239 298900749 824702484 365372177 -644327095 -895887859 -195339330 -42310217 775533885 199792154 70400939 -508316885 763100376 -323714401 758295585 334425877 940558147 -835416947 907519571 779796878 -761943258 895769204 474803859 -686614147 -494029949 887937459 380418463 -829255941 -734301143 705272083 126401166 -510526255 766661866 786906045 -732754522 438703231 468615363 -113002321 -293417278 -951671051 11546082 -84727309 385856535 -526128319 690837138 326273309 -988022378 -455643799 893859124 -684411813 -839645959 210656524 950978534 -722582025 -61352004 -897050380 533067667 367653066 405396710 122453368 -586209012 -109108261 177047525 802713788 -420459408 9…
Output: 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 996302480 …

Example 2:

Input: 106 86 882708944 -669803599 785303570 -682048217 352869161 772904282 -179037844 802950517 -405265347 -509004607 818591992 827293264 -597177117 880426224 904006038 -369232486 -121944154 -907049790 567431572 -63502562 -733067907 -795641211 -568799178 264310511 -114372257 474190449 -278682044 -445928759 -401796840 54838644 -775083915 317225451 328785728 -108697423 -271869573 29319711 -844512326 -613140450 -865973319 -454412493 865259087 -181286747 514822757 -869952304 829938178 -516243675 7472201 107579083 288990933 -874137927 -744927070 -91780745 -588933805 109699412 -507495873 -335229084 305709248 -397426052 -936309975 546243916 -618173399 -337677288 -557626524 -196443687 -957797673 303453123 599083023 -236221385 -885722545 -693162946 -327073063 -2061822 -692885133 -608177622 246860602 9691…
Output: 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969107427 969276853 969276853

Example 3:

Input: 2160 1391 -123445556 731872343 619130584 988198726 -709800241 772530495 -428777085 290613581 -142435089 -313589780 -729127525 -63197706 -21643937 246477960 600287947 319132077 721150568 -150633401 81834702 575490116 -420686906 139235074 -598808332 72752353 -852418808 -380940861 -199563790 -911327467 286456710 876138610 749884180 991980910 -228332338 475484683 -186999037 -543348953 961747961 -604264164 598101042 789295212 118756002 976211192 589637061 -892714458 787205938 407523916 -230065548 -537339581 -626324073 -927969871 138151323 22510076 967188890 -89801668 -285091614 314828705 -424016835 205284884 -952952096 -678585900 116999574 485522997 68430035 341524968 642573339 -390580713 -126289440 -963972887 -101107605 -542533060 933186539 -857091634 637783696 -831679399 -365552824 -672738013…
Output: 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 999893666 …

Constraints:

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

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