CT65094

The Leatherwick Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the tannery row of Leatherwick, Ishaan studies rows of ledgers entries. One clean number will settle the guild's oldest argument. 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: 213 99 20324294 -195298288 -934287847 -389298278 -615805906 -364967649 364690824 830787199 -406467431 445742453 283016828 215388595 719772492 142374124 281656500 -669861539 -979332313 921177291 11193220 -434986579 689269297 -725783181 -327428770 -449526434 -52656104 -874644878 118114144 183289581 -751906752 -733696108 528132799 609830705 -620655431 781591860 -770384596 599609948 -417710364 605561054 -261758261 -803614418 785676872 863900430 -933917836 -382486305 34071377 185261999 928638020 920531728 -91753141 181903732 212743752 139057771 752340771 543307163 248859691 -732299645 -305418639 -91835700 -486237895 -583586697 -197668082 -302737160 995880916 -911119481 -457898028 -113528595 283089005 -365292455 -120353815 -409043623 -622959757 -671015761 -823477141 962086134 -528084970 -2666505…
Output: 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 995880916 962086134 962086134 962086134 962086134 962086134 985873148 985873148 985873148 985873148 985873148 985873148 985873148 985873148 985873148 985873148 985873148 985873148 …

Example 2:

Input: 2717 780 129728731 24657172 346384833 40271252 -34744772 -133835245 -979755999 -795385946 823331528 85000698 -628856900 -965098994 856114650 -266478615 -793316729 533001926 287032144 58503071 -818978674 -153754175 -205647836 829035187 -574003164 160755744 114725509 -247236482 81535241 -63415532 457163520 976045440 928095884 863271085 350045933 786663056 -990973718 403028517 717124845 -655119080 -901893999 -481257280 -732344605 978901194 -27346532 -639339245 210518715 -162365204 -613602519 469013239 651472282 201996479 -51218047 875931393 -841022780 381273462 -872371139 -141567151 104825170 741886388 510049346 -103117579 -53016470 -852138491 -576838061 -296915709 -301563284 108114400 706469589 -818336355 -398397239 -987934090 306803274 633008808 -493259862 -622115746 112660621 -343894585 -1…
Output: 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 997138734 …

Example 3:

Input: 3620 779 14670328 -827381987 -308145679 -598929303 -543826633 -946826327 519786968 -296758571 938813413 -666677417 -615194899 120130179 -811104002 -82452146 2765969 361154803 -176441133 -377428606 -58156342 831937608 251697889 373086155 251750156 -592828379 -14322083 293787684 567745339 783724926 906990304 -16407639 7973472 710392655 -241445598 -720493925 -834285831 -252101059 -937432848 257897328 746288708 284312188 -685482866 -666587963 579768770 688368077 -522953551 864803239 653421355 484842427 31191682 -220118212 594094095 -698621881 -203326545 -901319017 -289507825 -33136868 -387579079 -93844057 -329358068 305419733 190008797 -509899906 -136637378 -169648180 -612889335 -572016727 -792643606 -992394615 -328194581 41540141 847277184 221871659 605347452 -300346977 327006418 -657931347 4…
Output: 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 999134405 …

Constraints:

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

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