CT61002

Varun's signals Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Varun found an old ledger of signals in the salt store attic at the ferry landing of Crosswater. The margin notes pose a precise question. 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: 3670 1780 664057931 427860286 -810811570 -186669776 619033914 102131616 751064453 -305270777 640220701 -178835029 -222464065 220517629 334976283 -224337656 -103006298 253114490 185623166 -265773467 963390354 657575211 -893681601 621887469 415883301 672791798 -969014351 331369034 376350840 -796937395 -726790661 718818107 335002748 -364526903 -454287728 -134743800 -204413609 -155265416 -892999073 763373565 706805615 -472083401 -997078361 931870482 788258093 742254227 -841000149 -447158552 -741483216 -162321361 -567894401 842892162 -941378886 993444664 -657072116 -211778936 793042737 -577425250 -784445986 795744411 178038262 -776915250 968094264 746232696 626369818 352375095 -218692128 653682212 394266852 -332250329 254084871 669870984 -129838664 -343858650 -916293817 -321816675 906972109 -48…
Output: 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 999639272 …

Example 2:

Input: 3210 1958 -641590872 -884016330 308731094 296470807 87403955 -893099312 494800709 -604948905 -644837095 259806128 366296396 388812434 -99629558 -360422602 -964733583 -222927717 525443279 -292899472 83947693 -771131065 -936529727 -479526156 794011108 -836586979 -534680829 -518701777 422812780 -752426656 546106214 -1183576 -601684580 -920095990 253176559 -304390613 -365991313 916657312 -204567473 251408787 -211346943 806744175 -707147065 -73656545 682513073 487811777 -326567616 -335133683 55218014 906929821 -784905864 42814353 -462436142 764464501 295356723 -135677426 -913181535 391336185 302714067 595830950 -553339541 501801148 -989592665 337261361 -32076692 -389238612 -390681775 -360959767 827286780 114418346 -573658604 545648826 16573291 -943630632 -517532736 -465358672 -866952506 -227664…
Output: 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 999044487 …

Example 3:

Input: 989 41 886892920 977748456 138613396 699056189 -959996752 -161887828 33830596 746352591 907610328 -566142254 648887153 -3432546 -82021169 834090879 737284802 -414533865 181903127 -826875080 344163437 338367418 36250415 600078177 975136719 -502047956 588578899 626284180 70528183 595934026 -287733780 283240237 385145374 -349803569 -729326694 -586674139 131290962 322543280 241409684 459794613 996381744 942177954 -455437195 -874830950 393065809 -892711115 -252549956 -448690273 646988249 -454780656 79642893 -436230587 41279973 -809394484 145553733 954522295 -858917621 -962527998 -24725964 -994169331 960340095 8010473 434744470 743853520 409852692 -362108538 -692043856 -499767466 724841157 -623440339 689180057 -304249871 732108263 936449014 27436571 651649760 960545392 -177434595 699587671 -6094…
Output: 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 996381744 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 960545392 946949120 946949120 946949120 946949120 946949120 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Varun's signals Reckoning - MEDIUM Coding Problem | CodeTikki