CT52215

Last marks of Sage

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sage runs the print shop at the ferry landing of Crosswater. Today the books show a list of marks, 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: 2703 444 518478047 998881325 44535935 266411032 979421992 -415296976 319558815 328937477 -659665834 25332474 -313636300 740150643 -766226305 254036633 -121767237 785227668 899400842 -436520183 -409580786 605176413 -898046943 -371222334 988464551 -963665862 -902092242 -158784427 345961056 305763747 -539135729 -907706524 169388436 -524255259 -807594167 109045147 -114102609 126705949 -120790558 -511949014 -147529056 -181214330 391538127 278993327 715569742 185961794 14402955 496987118 -710874344 -997729401 -546273990 597173530 -273043999 359483717 -891243017 -319283596 245845573 969237520 695413010 991088098 -409658026 -351831540 -749138368 -667867870 470140566 840657119 740005845 168360521 3897986 -297415275 -284521648 420081771 244648448 876234051 898583791 -693268698 -631663867 447021612 -…
Output: 998881325 998881325 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 995238631 …

Example 2:

Input: 3027 991 152276356 885436267 -40534311 733291793 546461703 -291528634 -377829792 -898835974 434215906 252673838 338548387 -845902966 -517377723 -580196678 -540083594 46999485 307136378 651180964 96375891 281941005 -421053178 -195064757 52782681 -423380537 -986294762 487713701 -579053512 -168790423 -149791449 -870700336 -879856084 -589711705 813262042 -465749504 -701397652 682303085 -65144730 -478065723 -237394921 109133826 288023347 -656604922 -318848594 -578309697 -5210961 55902539 15161145 -866132473 -738369765 865137155 -105518420 -877881786 -243438198 358380392 -239508296 -105139342 -67842469 -986190074 -426283189 775956087 374958297 -749539046 441050046 956383054 -447908621 202058976 -352338729 317917066 607175873 294296661 728284099 -119227923 748211421 -796119411 467876227 48966796 …
Output: 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 998384405 …

Example 3:

Input: 3238 868 -524044505 -826067405 -876901708 -525990202 -153723158 -530754246 44908414 -525932467 38296592 -813168447 -95374231 -88708224 -168093403 -300243538 -579356307 531778435 -596013020 -933368063 -511409240 -39539451 68911827 930286046 -360625053 708319354 338749148 -690538901 -213668301 -17616419 -105837110 -898788043 760480589 804829058 257644929 487943637 -566013430 622261528 -741602162 -35879737 -767139074 905311420 319863048 -627141648 132303801 -43023178 390799063 -193356527 741886860 655377932 -727434696 -535890081 130944204 497393401 -183481088 -912364143 -949036249 357458688 -98547139 186734599 -229816905 345371784 -374205624 775108034 856390239 64698019 -529601172 -143502721 231647094 -514004169 -616574207 657080391 537165607 -869745351 -449369064 212578285 496161373 -2834555…
Output: 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 995244970 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last marks of Sage - MEDIUM Coding Problem | CodeTikki