CT58220

The beacons Peak per Window Puzzle

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the salmon ladder of Rushing Falls; Cobbler weighs the day's beacons 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: 2985 52 -397669798 -430812862 525716750 -285404404 365901588 -405212222 -229360019 -626214961 158432128 233186526 615215443 82632 89450296 -640978836 575890084 797461107 196075454 -976858801 -267363696 -243024625 304628047 8275625 -912634360 964157946 -902241121 -59834611 516917162 916021785 -691219279 -183251815 406140565 444129535 922075886 -953579261 799187563 186010337 491003027 199140115 109954548 487670294 -668771100 -684851053 -513900302 592017435 285289842 -170825842 -313239295 -158027706 -833652060 412008683 752623922 -839808954 523622679 505665602 -779787462 635222408 310001323 286254016 -419186097 -117113788 -24945187 -861288225 806023437 -606577479 280929197 219570904 -441165887 173234738 486785564 -817493351 690236049 421202707 -145085922 -357981492 -79282793 -299689171 -29159…
Output: 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 964157946 922075886 922075886 922075886 922075886 922075886 922075886 922075886 922075886 922075886 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 806023437 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 966957242 …

Example 2:

Input: 3681 2117 -173820148 847073276 -114885190 -715400976 -44825833 -768556445 -543122067 18507381 -952295399 620785686 460338316 221514679 -280748920 945496410 -515995747 225073765 758754104 -751728752 20851263 892143291 5030804 -860025747 6754321 354703248 554285013 -631436015 -979227394 659492183 -241136276 931782277 -510736854 659973424 -365752516 -492503599 -110946560 972371178 -339632052 -81194251 -18200375 879320033 670304732 965087030 -657793198 -270112985 858104690 979989891 -901307998 -58967212 418074677 -65620294 166724815 -548562492 5150865 230571476 626835279 -868382621 706844696 19565713 826836792 -470712605 -548983101 -144910971 606170017 283340006 590732188 181341767 -560487357 -738697474 639279990 -546047711 -317054926 396205925 -640445851 -396480008 825810082 -336581869 959939…
Output: 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999012627 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 999986467 …

Example 3:

Input: 563 230 948231498 -894459794 763628770 854503593 801707395 835211972 -580011197 552540946 397368340 -186241042 -180354686 618431362 506065129 671851118 206602254 -831651520 -598844949 329967112 -424042042 -513929952 -628223347 989734929 -594854668 -46171787 890912431 -36726514 437259008 -794656235 -76497764 324500215 -902308595 -254428760 -335962086 -992781915 327062768 -455496019 -484388102 -688326867 -423522246 -515790173 575812623 475918360 -78536823 133017949 -876160704 -634328205 -661635532 686068735 -935032200 -61046443 524143251 483264702 -615046627 689731646 -75006266 -672282752 -55843983 150278379 102125800 -399711404 292205687 420521183 -961594456 -203786569 292695570 231872326 -589918294 -3150698 -82639457 670579454 915869297 679863545 744750666 -476668803 -714929555 121347049 -…
Output: 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 993100011 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 996841015 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.