CT49538

Azure marks Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The log keeper Yash has been asked to rebuild the damaged itinerary. On the desk lies a long table of marks readings. 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: 2674 1287 996036895 900036501 -510906954 523737815 -24111967 422579130 32674441 -721365769 -927922646 -622099792 316611641 366291587 -742899510 725507386 -714090663 388448957 -447737492 -328571993 341131605 957651770 -264404513 -361174980 794191710 766126330 182908342 -670720396 -66412010 975825919 -479772784 -643487799 -248952259 -170831772 -192843231 265635567 -358090475 -187234511 -308988209 974673113 -976797561 -634384572 133497072 -195352241 548919073 -426031762 -428369200 825377071 877633327 12682967 -414181725 -85631096 -670759007 -744599702 -677955488 -344205398 -580845081 74425538 -446051754 922711958 534898204 168526498 -995629983 248053457 42241269 -428783768 215596089 -592685316 400036784 65895716 12257049 993901541 804983717 -282541173 -453964849 652930519 -107376180 -45429792…
Output: 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 998817267 …

Example 2:

Input: 1241 1143 186713778 -682167854 -849408771 812186564 -550255131 763161965 -258872328 869900314 -203124300 -852712985 580047397 -300500674 906964311 -606735701 560927300 -756742378 -457894327 -282242472 -265730096 -274700376 428403068 883360913 654136469 628361501 -575659917 537257750 -932003207 304646201 -116675051 -630620460 -254266493 988123786 -909264908 -435644498 -129553758 744326406 -996967442 -359003669 268896438 -911122873 -143968223 38590206 252808392 937386361 -387491306 -183327223 522554653 -109803678 437863196 -824312380 6419788 -448581656 329317458 -873646313 981299389 253850686 -959028625 -207749119 -2176951 -643161492 -429438176 696225035 396941023 538432487 -251850810 -681021728 543563703 -893488095 -419019648 411979046 583406388 -732544161 -743256970 603838677 -251728140 56…
Output: 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 996667797 …

Example 3:

Input: 1616 1562 578095093 -919809443 436141121 855337091 981492570 777666006 -600800371 398596799 -490014032 432472106 -95857035 -248777959 -178505982 -882108719 -66472137 93691782 581287659 191362207 -160147330 662347650 -9462057 200430620 69535985 -968694380 -453172888 288815632 981750313 889289469 -824450493 -503304308 -813832512 112648488 588764446 919069695 161492107 -483473665 -523926790 445494846 164193043 917539578 772566660 738567634 7581377 -70499250 69111877 834133203 -212425250 -243328469 -596413680 921298926 673683111 -527738934 -788343981 54854719 -387717115 -244733256 -853381213 193214036 280465676 499256481 861221957 740145368 -213334993 -604132801 -734255993 492961403 987546154 140865768 20459734 -958366421 -272437526 -518722010 -380406261 103375311 574544132 -514692113 -3359014…
Output: 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028 998977028

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Azure marks Peak per Window - MEDIUM Coding Problem | CodeTikki