CT57383

Ivan's Peak per Window Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Ivan runs the dairy at the poppy fields of Scarlet Plain. Today the books show a list of registers, 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: 1679 833 595231398 -830914441 132946266 963471633 358127535 -747763223 453054038 938818354 -638129487 -724704340 -493386207 -985592127 -397550198 308780267 -927270588 946980571 -936518711 -204756575 -510756907 -879006907 -867207781 944199808 -187959508 755660050 -967229385 528846998 -669781537 896393634 449385996 427070748 -952467894 378183894 -696652518 313464127 308603657 -261728527 457809516 -349110923 543377988 141506860 -156514248 -88561351 -835277735 -715640003 470380853 67513349 -709577414 905111126 -573644256 -407890217 -907061663 580678932 -851268260 611010482 -676621968 591784439 761072077 571425050 873784013 -958781875 -692944208 -63536381 785686961 681906568 557683285 114019798 -192958208 460747390 227596868 -200061656 -180818397 -332500617 -607246729 -8086169 -505976308 -21653…
Output: 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 985273814 …

Example 2:

Input: 1825 1269 818963073 423254981 -872303449 -977537544 -795995170 44967165 -219270939 771550356 -182927203 833688191 341385851 831938694 284329795 -415766632 -791859393 406251752 -368242136 -72162514 -166366789 819252040 -947130022 -495909219 967072314 686915106 489379462 -696957693 962480001 -502446893 -63794905 -373970426 -357758749 -799770432 -111305725 831502583 713981223 -707334370 -843755502 -894811879 431690461 -287554548 517509873 776305701 357836066 -184178919 -281654604 -406062222 -197157925 -554575563 -590776978 -949458219 -960746022 945578814 808852416 316344634 -391935463 689046077 -135842382 -751896996 -942575450 523547673 -138814841 33099953 -873150656 -989137917 -512821684 -887436507 -812731114 -654137785 672958533 805957454 -201852213 -416958433 434088834 -112929687 -41403623…
Output: 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 998987609 …

Example 3:

Input: 684 112 -395907947 579717673 -753419866 -573742131 -598022451 -240467113 -178366260 -422273182 536312916 -15168005 71093099 884317120 732079532 -681103758 559284647 372508038 924381714 -579938241 -783649300 -332344466 565004704 224448006 908045862 80048824 535889123 -437496850 28234351 707683465 -372053803 -632624963 908720249 -986642262 359002028 731277106 -143954642 -991951507 -154675625 999524086 773447416 -463426900 164252160 967387772 -822778117 -914229148 617266417 871780469 -887155592 -578972498 -203573960 556630195 -57249751 379599985 433316533 -922041060 904989244 -234042204 -204234516 -893644276 -307845751 493144705 -391746705 -610887186 229472241 -614642459 85089530 914498986 -13942404 -487200859 215005239 -498375872 -707014583 -19877098 -667349050 806374542 -350257927 -91957926…
Output: 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 999524086 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 983635322 …

Constraints:

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

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