CT54251

Yara and the Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the lakeside town of Mirrormere, Yara studies rows of signals entries. One clean number will settle the guild's oldest argument. 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: 792 622 -43802490 -918244639 -776681115 -113169089 -796648431 -145614548 271793623 402555448 -481408454 -227851094 527430259 411310153 15961527 -501007502 -768895371 569961919 -613696087 -18108284 275279458 -748562458 27542810 741382399 -934390776 -509451496 866909715 156004628 -108952986 -891387914 684421952 -883986506 -92145688 -540449268 -947089502 -755021479 -966062923 -704518727 -346754895 505394254 448960908 -905939386 -237366973 735648367 793041239 273558373 -189733530 570483474 -772964402 62414916 -93119447 41236009 -572188827 -937723145 -98016806 -636623270 930977498 373911441 -312112524 -360775992 188100671 -448499840 415948923 -31342976 -444007363 86155099 -827404471 540230702 -419263020 -190663728 177740961 -136369154 603802473 -347788375 -544011341 576488534 -457025655 1013857…
Output: 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 995807978 …

Example 2:

Input: 1037 255 -724401517 -291354410 709956358 -636274459 928267799 -553638000 -83896683 574461586 327098392 -445703369 418470014 -355207876 -430316864 968352206 114938795 -770768620 409499609 -609876549 453775610 -512178675 -389850798 -687139224 210467983 900148982 525404661 929863942 565921064 162211364 -83183901 559163941 518808980 -358656906 562775482 711510474 -416591006 -702024296 -257150040 -130002478 -90657756 853842308 945801692 769439084 831852145 298548504 926612166 474805908 446424338 949351834 -537710792 739960637 692176465 197906301 494147897 -935049880 467839252 -614872970 902964703 759816291 703114563 -201248016 -481011847 102696425 -471358703 637211273 709575021 754299468 -976210684 246227725 -99225450 398396502 266166417 -54211526 -53679556 833808376 -485020362 861929573 511642…
Output: 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 999325445 …

Example 3:

Input: 1724 324 -335723879 -17301228 771557397 -249449121 24992358 127444568 772934604 398596593 798876886 988751391 236995095 534112461 566809302 -512054045 736281022 -81855773 251440149 89748546 -25194925 -180315820 -477202802 807904762 -740605595 871818698 -657575622 302214226 -715361108 194561413 687429586 -403494937 -224224425 -463599140 -481476716 94670877 -894616093 -690009858 -532682806 -957953197 -558164282 139053911 153715423 600500387 -909158393 -481215050 -313106787 -363434257 -119709553 963642891 753535855 -938543214 107551828 980628524 987903879 15597642 -553695610 -898652392 -782500752 -778466702 812316446 -690470944 -27624893 -120972706 336998042 135367642 250331434 -760723606 -142212601 292848659 842792902 -916368338 -88587630 -344685713 -695837249 290046641 -581171394 -703772481…
Output: 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 998708652 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Yara and the Peak per Window - MEDIUM Coding Problem | CodeTikki