CT65258

Jaya's Peak per Window Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Jaya runs the loom house at the silver mines of Lodebarrow. Today the books show a list of ledgers, and the numbers must be worked out before sundown. 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: 2275 491 -758428549 202846835 -189122102 308459429 -298205914 -366955270 209289818 851437566 95249708 274139977 -180075070 -371787312 363358104 -832241166 139751661 -370310780 824902511 -830390521 -542515263 601922943 664909723 234553004 396928157 -34117971 -181747181 -704077734 -685004745 -681177864 605587853 703554037 -194814993 384527963 671641306 978066491 930780063 597365448 -510883659 -321118969 -695118823 446704897 -744377608 237615702 -970100867 -293429609 430404700 385538345 825353248 -507180841 431944413 451691339 955885543 -539293294 231352331 -897637057 -660244361 127268828 -482162681 -969573046 606316126 402243613 -873442437 364769465 34034314 762216647 -329100646 -434314108 -291079362 8260459 986729862 -176926844 884250645 -336327216 -458335828 -691412206 967212530 65326361 4…
Output: 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 999703014 …

Example 2:

Input: 2061 905 878028482 -81223779 923787640 -745634154 -566460496 597225893 736198160 223646706 -389898553 -371778363 -998081960 275129426 -669635847 -544242673 -63888873 630666711 791068474 148860546 805441779 19095942 353245559 -592819019 34313080 475130865 -775963746 828556574 -300075518 635107097 934464764 520390788 699739668 701641287 -480328811 -931169806 -134492075 -656755592 448822289 741538743 -571465968 742368682 -739115359 465482259 -388558797 515835536 303870077 -133028861 386863152 -154113225 -57673843 -388422601 645251990 512481790 -760286451 -408033807 -127302313 -384487714 -925804392 640591255 -199853412 -279476976 109792841 830031746 367878588 -83816627 -937530800 206711037 -380329914 -617957194 -22021681 -363246383 127726713 -209959059 936890811 -222654522 -982541580 317986881…
Output: 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 995481779 …

Example 3:

Input: 2521 908 60377701 592026300 545954817 -293595795 192198296 361800341 -376008382 -745966668 248226100 549945487 -952706114 -760884809 961223564 -731684841 -27168851 683629540 -540829491 -374416237 -876372549 845805746 43787254 845945711 -575619305 -435849840 491881613 -428492584 964689063 667693318 31976054 687890434 -869817101 -136328734 479571106 922764872 -153371914 -841736487 47777026 339191976 -52523357 63338300 -414262056 32668275 307800299 -924014829 -163701349 457242359 -572619447 913607386 276519566 277951214 -637675689 -70659027 -647738075 -158641332 816265460 444335177 -412349226 -765150495 -552560400 -644182781 693020146 150801247 20359497 -852556553 -189695536 -745764017 -547324510 -734757192 -127142572 556958210 -960655064 -390934291 -158540501 -603802027 468616366 -186234374 …
Output: 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 999868374 …

Constraints:

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

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