CT55875

The marks at Petalbrook

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the garden city of Petalbrook, someone must track the breeding season. This year the task falls to Chetan, armed only with the marks register. 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: 1146 1039 115562957 112124779 -868478129 -932918629 -450523332 528089497 -499988616 -87313051 348176552 -449209484 -947848550 -797824762 -159908262 -740998391 -28857360 -178672226 -509532036 -495068658 917040309 -968679757 334589485 936721059 -908982061 -518003924 -213230309 -928558676 -590016400 608786788 -137956843 356706743 812010171 716628498 435151090 -355093113 557908961 -809325955 643850013 925692067 -276536198 -751037371 944554276 -70160663 -506262802 -676713158 -925291852 -526748767 -112176491 -829833697 578341931 846240824 68112828 906214102 -38950870 -650020604 -545224808 -600174458 745228145 606001457 574134173 -502247045 -761392579 156468796 -668865243 -978798158 -394664127 -827324698 -117828453 -988696925 183726678 19422938 -478663008 348220986 385468835 160106548 -216660922 …
Output: 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 998021975 …

Example 2:

Input: 3411 2278 77420396 -538356674 -616287082 -333216224 496202465 41083999 635502429 -347885861 543980986 850096053 693425408 744557885 -497327719 337843377 448934241 828017315 -874721302 823741434 -570128419 -180690146 954560052 -773863455 -117325485 -252764237 12000119 -520774666 -743440916 -23903910 -139017481 -425324004 178487929 304039241 -162689973 -874884606 -512282841 -135776967 -967823999 917752509 437277470 -289055895 -317445382 -518888211 -977762700 306457536 522330166 -941490145 -916219392 -248087155 81656046 260257397 938146221 86249638 424527466 -940217549 -331259186 -30813707 695067279 884177819 634865658 731865823 -773763992 791425878 -858086098 524624547 -929846017 -584402363 313390628 963094819 -403897197 21700336 -360661331 377058608 213899355 -380935930 297800269 -587702727…
Output: 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 997956982 …

Example 3:

Input: 1286 1266 228694624 -951266617 -41012609 -838963165 289050053 36212227 -7028118 -102653533 815717001 229479829 -564641942 843627427 -502293049 -943322620 -324039692 359836938 605944201 -402216507 -424673566 365672093 -336262499 552070621 -255503634 -971037154 571417203 667223458 -668377525 72385837 -592886555 418982605 -642779255 142496800 897616636 458379739 181368045 754324375 709483659 -401425768 -775881659 -161381593 -868719006 204030786 -745277754 -728886868 -810927842 193644368 460372137 -65074529 287873278 -114518436 -712173699 806719414 -677395997 -562030067 197629665 -498180950 -161260946 174952802 -172989388 -964790846 -636981464 197945360 -224124301 121100505 -919607198 -138668792 676354634 857842572 326081834 610181936 -531842650 604268156 -890271017 -381357059 -25314827 -30512…
Output: 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022 996102022

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.