CT62034

Tailor and the Zigzag registers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Tailor the scribe watches over the temple city of Sunspire's stores of registers. A careful computation stands between order and chaos. 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: 2856 1842 -956734111 50190622 -909582284 -839563055 485789244 764116484 -525491255 882064453 -96205655 241955054 -56381729 -26442706 -298141651 -435335587 -716601904 -342087452 -327605190 505579844 507411359 511836475 -224635446 -927942535 440435785 -541988281 -953080072 -491976384 889934934 454805195 -745180421 -5263803 -855574058 -82865808 -445177302 532060141 -997095011 983635834 400240430 -673486854 -928935648 -86581288 -149920748 -544459057 854895364 -248868493 -463667766 476586293 -404861618 736531966 -133386496 50282166 -648861568 -315581933 274950663 -215682850 -113741157 662117887 258407369 890841509 -270427378 -619934043 698218530 964404898 630993074 224461782 -289157238 383129550 -628741047 531919431 -81317918 764044165 -656874285 -499801882 -889489782 946533346 79286492 -851070…
Output: 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 998292025 …

Example 2:

Input: 3334 2352 -724655806 913945566 64636842 824130906 423080559 -925968106 982389647 51045254 -261484660 -18311872 648800367 -659798561 -691165599 -740285346 356028205 300643275 -195396133 -801866975 -711938382 -160759707 -327597682 637611841 -697067180 846133289 198206124 -524551343 602929444 7348748 871289572 684222800 -612086012 676521997 -278238584 848836138 -401946603 -182570094 908162671 16641146 -364438480 -434160368 118536219 982425589 70209975 -466705047 131372063 360116809 -621662276 -311569244 793999100 168532562 -959543806 54827227 356044059 511140641 229242231 452319092 916645082 865766289 970429803 -826519372 638205670 747021031 809820388 -863667584 -539391558 822541738 180921018 -622239359 699677358 -265632439 42801577 -51710260 494211896 -391350479 1441786 -485071878 -934158886…
Output: 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 999075224 …

Example 3:

Input: 1912 1155 924495394 -529647498 -904811925 -660334972 248587369 135799575 343350656 -646613311 945308698 -566075405 -615000137 392790425 726025358 341769277 -552253372 982643615 -265336507 -837236984 953881322 -250609678 657332398 -502332792 -96590696 267205839 -588715058 -612445215 -231164519 -690165862 -327060678 271256129 -888826075 661484700 730872922 308908450 180903910 -89912478 -29534262 -729487113 67007940 597470056 597318207 -343806539 840328315 -194600861 -862696322 -180060212 -940750601 -568340801 -994188640 446932438 -468115302 801148091 -104079946 -26781092 528021016 -468381793 -424164139 663641520 84552403 -550325635 916381676 -233833799 960138414 -678028781 954956107 606904024 810340342 -992689082 585152651 209750218 -992857585 433462098 825597171 -384206590 813302542 3873033…
Output: 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 999523484 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tailor and the Zigzag registers - MEDIUM Coding Problem | CodeTikki