CT52195

Quin Counts the beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Quin runs the foundry at the desert outpost of Sandspire. Today the books show a list of beacons, and the numbers must be worked out before sundown. 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: 2364 1839 285407734 322371187 656044567 -896486683 718245418 381781177 -274908645 -999994022 -180807113 447608773 -936180561 -966180240 595622517 330164816 538184061 817906051 -716091434 382894898 569741284 372461139 266365353 307324988 619140970 -648020379 804778658 -855450164 717444525 -29076237 -292652159 -778377353 -752804837 421260229 621323675 805365730 -172135387 818215832 -6663568 -225750407 -695616096 -31204869 733599852 -164285100 870394228 -578048597 -723521858 -234637760 429983778 -681200524 -433298159 -500096268 -715539720 -604280525 708680010 -72892014 -437299385 434504216 -925164835 446736138 -802492141 -990940684 -248536651 64066665 909527560 -195495297 -453687079 -77364615 -38617425 973534600 -632025410 201993826 -983928850 -903139939 543417453 408578243 -1288374 -49505901…
Output: 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 999673287 …

Example 2:

Input: 2813 636 -75857579 -725657010 -378865256 586617910 261986625 167446597 453710949 -822708200 986385930 -451296272 -549639566 994956712 -777720051 -875548620 -329524103 -194742756 -530963204 -880529884 194996506 -490047531 206501713 -443321520 625562385 -567523246 621769003 -831711426 892138111 -50565622 -228899056 -799320075 636925165 -515965637 54282045 391385134 -151046007 -864247562 -405908391 568999995 -342635124 -288954122 -254828115 335067964 863139746 437755540 -87523600 -11382943 133124951 757445632 -505511613 -256079644 -229572922 -226270625 -471088412 -524570805 681445819 149368694 -649649481 -946819717 885891394 -474249503 -599553124 31403386 644939768 62319903 120709217 -404340743 -188236624 924462723 -639852111 575099400 444823919 242466094 610396452 -301702240 931663276 -68750…
Output: 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 995550344 …

Example 3:

Input: 19 3 -252623961 -222594483 272629283 -97044449 -465601434 -134751542 -65417059 -572837511 379914256 -374997098 109252538 944149459 309265118 -469202078 911069776 -806184497 -155720230 268158257 702125941
Output: 272629283 272629283 272629283 -97044449 -65417059 -65417059 379914256 379914256 379914256 944149459 944149459 944149459 911069776 911069776 911069776 268158257 702125941

Constraints:

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

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