CT53847

Farmer Counts the registers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Farmer inherited the chandlery at the maple sugarbush of Saprun along with its curious bookkeeping system for registers. Time to make sense of it. 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: 3229 469 563411671 797189434 -645121475 780361977 -255523795 930761115 81267223 613988714 242616211 836097505 321857296 -323354501 -696170229 -795102496 765442820 977110002 -151965343 -793843805 85956289 -962000198 348710364 325013599 -606987398 -409184358 -903802226 -702910781 591021632 357543992 379790954 -668958336 -958143402 -295757353 811145288 177925393 946878452 918019172 857671055 693326488 284394998 -61985719 412287833 -736150937 -830981600 -31851292 -908125289 -147926702 -644714728 499890047 833951567 -197345030 7906849 17106197 585028198 -728422164 200024611 125298217 -344615043 261051525 482350601 89291061 -784275512 -298665190 -342127564 -123971474 -687157193 278267952 -879982408 -840130004 524412488 830937090 -683601900 110288606 781976409 460308155 449728617 345128680 610683…
Output: 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 999421586 …

Example 2:

Input: 3066 1572 14142614 -368252259 348582899 223126519 -780114084 457385444 -859048804 -960364777 508921931 624429371 735901286 -505951273 491367652 962130596 -686888580 -410882488 -749701956 -107858851 -30942745 174434104 911607256 -762269934 120567953 -746245585 700330968 956170680 -640508905 -562281721 73702252 -718617556 80206118 618815616 618174824 287686043 870318814 809736592 787443385 -276715547 216104655 477567693 -872780840 -313763344 364261008 500053893 467111200 -596139502 -636070064 643730026 97208240 957586205 1014588 89122496 555509328 30680388 -25638763 993330768 -756884575 633095170 389768104 -497250807 489427532 -492380571 -169802550 896187621 254856154 -306421298 254034214 942705578 896587004 18703868 -796106019 -966761757 -774971415 -642880442 -721829996 -399034118 -96210970…
Output: 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 999767243 …

Example 3:

Input: 1410 120 429785025 142822219 695650941 839224345 -790095449 300341986 -983584217 945013518 -171174144 615757877 950489466 -134731229 533703446 -650589513 -243127197 -464028651 -915274970 723808854 -944122047 -755939331 585631013 766057420 -160506738 294339120 270363613 322846320 844670055 416683821 -621528268 29499717 552788038 -217254512 -462674722 -202947233 -298199450 88544043 532661637 -905521297 -819739515 -939632211 -595298486 708756327 -564360649 406395484 819281525 -136537641 133731337 107231399 -511690665 730521933 -845336865 -43516929 -337620232 705949591 61677519 -735710521 909905582 -862018586 114448361 -188265969 -951888832 254345844 -830661108 367646903 737823395 179379032 -238191972 -161071940 -183326888 27972062 285900294 784845198 -397779508 980833957 -2272865 365707925 21…
Output: 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 980833957 979735563 979735563 979735563 979735563 979735563 979735563 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Farmer Counts the registers - MEDIUM Coding Problem | CodeTikki