CT47043

Rosa's Gilded marks

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the steppe camp of Horselord Plains opens only for a perfect tally of marks. Rosa 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: 785 600 50177455 -567871161 652109352 -168174226 768437843 -761229970 -699287356 -713998670 -455506168 -518494687 312948633 248469791 -699313415 420341094 782745424 963988787 755317204 -644154113 182581950 -247860448 -873780868 -245721463 407951923 85378926 407791162 -835212396 432185484 921725607 -106224137 -444836667 64570274 -738388571 -584117097 726135932 786254124 884391491 -934345805 79959214 -161876435 -392544352 -953577366 -797958541 745139176 690203760 580514318 -523980144 -941364641 841990311 -431921326 517984135 -822142634 -55352684 157117717 652531553 -39058983 974581901 234231750 -706311098 139055479 416849663 240535598 -762256824 -224225822 731107075 859477372 239716518 -476875943 -135603120 680418221 744905612 322896091 870515041 -655137816 586889505 -193526697 114824550 -59…
Output: 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 987518382 …

Example 2:

Input: 1849 1372 -894216363 -50835905 208970426 815290799 64934376 77086822 738001581 -36280304 251126925 951060222 340267522 696599104 292764318 110396210 -159888408 390677049 -753361230 -103799900 415486558 -374315300 702616484 438822630 -230922374 79851076 394984825 686774989 193801906 162432583 978917455 -626800857 672493048 129302637 953899299 -654525093 -124994554 876919452 -700246963 783196847 727840727 -757474743 510288833 -295062643 27858379 -868973939 -890377896 -420788199 -811693300 234557968 -126316667 -917448966 524551849 764966308 -265701817 172697684 -952994497 907294731 679990663 -635044768 -289292452 736971730 -782777028 160580417 258808600 998727586 -776256728 81005821 291947644 861463413 -654349189 -649729342 -612442405 570571115 -527382959 -516809473 -734576995 802015730 -9113…
Output: 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 999123383 …

Example 3:

Input: 3145 142 992426208 -852677069 -912399448 177612825 664421155 -71223262 203783359 -25502299 556398947 274471168 550540319 887865007 774848641 220917584 -662671187 611757902 281290855 908934095 774993659 596322465 -396868829 -633407453 -341861397 723289158 -247796240 163079808 -916433133 -10045487 684112116 274762769 -323840592 740758397 70530345 -172555994 -590127324 179515181 504042963 -363573399 142620621 786446903 -811475253 -642493348 581270799 -306931124 -788110607 488932990 797366314 -968328190 -945164522 484420231 -837988103 -253438797 189452744 -36496775 930217725 397357913 -465288152 -950017110 -789607450 -304402135 706278592 -391290172 -924522764 11993007 -238267225 460383112 596584713 -38379421 463857783 295011180 -972278092 812440297 413379262 976048571 -857352450 -912916810 -34…
Output: 992426208 976048571 976048571 976048571 976048571 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 996929030 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rosa's Gilded marks - MEDIUM Coding Problem | CodeTikki