CT41444

Jatin's signals Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Jatin found an old ledger of signals in the studio attic at the wheat plains of Amberfield. The margin notes pose a precise question. 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: 2748 1558 165351732 184377452 979044460 -879671563 67091030 -186679176 -757748612 882409240 112946940 -780844403 -411458760 91240234 -656360905 -559804524 -678728463 289608066 175408297 -715072193 573426111 195347541 217971359 921172208 -104624825 346296794 -362288564 84063697 7586461 94276604 532138005 -575588046 -772800852 323743988 360968428 -851332898 -467511858 795445650 983849753 585661136 927815111 634439357 893499711 960944851 226795744 447358718 952563108 636836753 -129107050 381471548 947364255 204765361 -888016110 9013027 591667896 -490939591 -592245258 -985794774 40792609 -409805521 368575492 -905119793 -840420269 4714665 432560281 353458930 688674270 -312210278 -705096077 356042496 -804740434 662720124 723765549 -812535728 -626276911 -46598907 20428502 525705171 486123521 1084…
Output: 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 998419691 …

Example 2:

Input: 2022 1849 593725663 696547089 -507584933 359386475 32200883 594988954 -996033231 -911407408 970723064 147324913 222981789 592104491 -668676873 -5447032 409747863 -212291360 240724246 740499328 -504155038 989311900 -874800459 543406862 -703680759 57660838 223349039 753857447 -542049803 -828407476 569096056 -825457745 -318998637 431800130 738755900 155036818 970250757 566165555 277218690 827341812 -701493697 945866641 190878678 -158915301 311931458 -135221057 -169711267 -54485611 -492604019 515398055 327399552 643225090 -130860155 -135879202 -915261656 -753694870 451101330 619282475 91721812 60925725 -789240577 -255188894 960779800 969818317 -986908924 159829606 698408978 480756872 -590457302 -491400269 -483592385 -860206604 54673839 -669411293 -865495290 -508624783 999473665 199965826 99701…
Output: 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 999473665 998450540 998450540 998450540 998450540 998450540 …

Example 3:

Input: 2017 1320 -187694573 84266842 -669269374 945383286 -73856350 72410136 772516654 473198893 -45356511 -386964265 -867595752 232966465 905428103 -69919496 -997705557 261215786 -183405411 732221652 -588718595 246737334 -100474866 119977521 809487852 -824656488 166954018 -898265213 -765997026 120368392 65845314 -773139907 21964858 -554074300 820608131 -669400994 622647119 -650008256 891891285 -261535589 720704917 -764375980 476111953 -285143928 -694772943 -975382802 973099524 313165852 349192057 489117988 975092127 593601557 -396286339 240023516 317223093 698963595 -708242034 -361719813 987718163 602763742 -22956017 809534511 -301796395 -214028776 198839509 443204413 -185547322 293322123 -495112641 822121442 -441474986 -473101392 959795094 994122322 -62455038 260598660 269405127 -118627144 6796…
Output: 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 998124120 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jatin's signals Peak per Window - MEDIUM Coding Problem | CodeTikki