CT43072

The Pearldeep Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the coral atoll of Pearldeep opens only for a perfect tally of signals. Opal means to find out. 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: 1939 440 -337340183 197387574 -887061030 -322709909 103313863 -260676332 221502656 -802181868 -151017619 -644507457 896503103 155368403 603726398 -5898976 -356488301 418799001 476620711 724486356 285567641 -356993178 495560179 493655861 -352615492 220222918 -43355825 -143859450 -591515895 139551664 694152099 -688892962 828404961 12728603 404677623 -761608318 974141419 251785522 507918488 -817529419 -425578650 578883357 -777620955 -895032869 219213764 177575807 862084705 -442903124 -730822292 473856871 -497155777 66000335 -238589713 -374305917 371264350 -964431928 -338232321 -403015093 -393534577 632342411 -137248893 -240607867 408157921 -104657100 -259948307 426064218 -726016711 990305929 -771998206 -200001066 755161446 -423535549 -983996248 -287193184 -141267355 639516731 493475847 902013…
Output: 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 997733296 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 998038590 …

Example 2:

Input: 2961 345 646107894 -613032970 3909378 433427915 -952749703 760545723 -988548635 -845709824 744252308 -37407947 -841057541 -323016445 100092143 -561145236 319219063 -153347898 -695619313 -436125180 -748511700 739395426 -186737294 -445799333 400465041 -871703703 177103477 162609153 881567254 29632789 -306668563 -605098360 14172156 794429316 -730415537 -274378561 6678292 492130230 -345774925 -100532162 -110321397 -780778897 787614274 99285249 -547781542 -354416040 413182288 97195205 896733033 136879991 -755997681 334796436 790329271 -363459100 618953574 693863442 620967827 -914870769 700468041 41436928 -82121231 627199849 159816455 674688486 -479084371 482535989 -137519731 -347777032 24320249 -347419041 -798313165 -555360960 506115421 -270912961 -529412284 -640682051 -448694100 90155150 -5883…
Output: 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 997505730 …

Example 3:

Input: 1064 747 -899984747 -914772013 -940526462 -957678831 -984616507 254802736 -664668700 910940079 -555964895 785189571 -749185107 270792251 -539629534 195605624 97716297 998003994 729749700 -255961529 -822334149 453143779 501328424 -317419859 888415104 763984884 370494697 246683588 891822499 804116049 400759231 -233121865 -964360114 215857475 -49292073 648913920 -435765660 449991723 721261841 -99987110 -171481181 474112125 -814526460 166729019 950965419 -789694904 399443882 994619368 113461865 144709690 -988269713 922065177 633459107 -363650895 853917528 839315249 972731477 421156362 114571325 930571625 -102145153 418505535 108401828 747988216 -277933152 -145855110 730599790 -500778534 51770495 443657653 -426314382 11282401 174824707 673502456 118503582 976506052 -742583474 773184890 27190265…
Output: 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 999274054 …

Constraints:

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

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