CT61687

The Barkhaven Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Felix the tallyman watches over the cork grove of Barkhaven's stores of beacons. 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: 1857 518 -837332147 -872088939 -457259017 -366960577 -845797476 23673862 -25238932 657807725 379640721 -378426900 -179876612 110715815 -562538588 357548210 316718714 -208824186 -557204345 -818438619 148314020 -624811759 654076718 549934929 478693412 -587270930 -536729609 -222322978 -594655151 483319063 506355657 817822729 -258613825 -594933309 982471540 947903322 424671533 636201413 -167375784 -276095846 78651474 197412784 73002932 -377282611 4420384 -846034832 -272419877 -669909524 958860531 -755161147 795257169 215126728 -749206709 -633327381 714892013 -895439598 -715540671 129506246 282462790 167776102 -23686107 -423721885 -730410478 -187153672 215536242 770918507 808753749 336572982 72119631 -612478191 -980148609 303867254 329840209 -845302485 653621773 540071965 369731183 -327318160 5…
Output: 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 998783709 …

Example 2:

Input: 1484 157 -643241711 424654251 888477343 -81620281 122503974 104408246 468920633 997051080 -282331394 987215093 -854465698 745061865 -41643839 -488797092 -283714795 -878563602 327738051 962239812 -565075649 -838099858 -603230816 -576820925 -349595674 93101238 -45523592 -615977736 753505330 181694646 396698190 747752515 910215934 -646899816 -296068309 -549845331 -978247025 -780464874 -113534024 317211467 -845938541 899093264 -122190014 -864716712 826822336 156822940 384383785 248940942 -244510537 262255314 812892869 197697604 -263437679 -388064863 251126512 -180870476 -859457481 -421592958 -960790350 -370060082 -513959207 452771190 -595567746 -437033066 -19259974 -490593179 297002306 -633187346 24016863 -256548668 29697545 -437949368 -997060415 671821438 -635508589 -326479734 -222980699 1732…
Output: 997051080 997051080 997051080 997051080 997051080 997051080 997051080 997051080 987215093 987215093 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 986164142 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 989751227 …

Example 3:

Input: 3887 59 -732198791 837523948 600359629 -794746846 -22755422 925285332 187184351 -38693455 -692991993 282492927 708809826 988321960 708832155 371734625 584390189 864774270 317419661 562017885 -579730456 382305231 -98014434 787255246 647164785 523223791 -781337432 299735237 -585984266 536078768 310733833 -672609003 -824383725 18584417 -818994264 -469380352 205475346 -989635055 -104267245 -566775665 25434851 -340317967 170280743 -186793690 4583598 196450513 14014023 -596371639 435815732 565045883 11722924 991031826 486608177 -390882317 -365055217 646160266 682262583 115395607 9121257 -135016354 -689470314 827723351 998902202 -417650363 499391215 -293211847 820322854 564756501 -41501363 -766244222 -666748820 702278995 -410417505 46119993 402063885 902171771 318309391 495555211 155155830 -16067…
Output: 991031826 991031826 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 998902202 974506562 974506562 974506562 979254532 979254532 979254532 979254532 979254532 979254532 979254532 979254532 979254532 979254532 979254532 981361229 981361229 981361229 981361229 981361229 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Barkhaven Peak per Window - MEDIUM Coding Problem | CodeTikki