CT34374

Kavya's segments Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Kavya runs the exchange at the galleon yard of Masthead. Today the books show a list of segments, and the numbers must be worked out before sundown. Task: Print the maximum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the maximum window sum. Constraints: 1 <= k <= n <= 3267; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1864 251 896628191 897355855 519729203 871505256 644361649 439413524 836447557 592712246 755844939 167306001 788797089 678149143 999387450 916738446 27250089 154108548 469365592 705313000 636487533 897094332 593038322 713685284 737485732 682857800 208734113 670634070 553949294 549413365 895733664 529388681 636427081 786215756 320583805 16476585 315493606 632539290 139420415 832297640 104353687 106741240 248334612 664599941 691374606 288904467 850741794 988702579 243909488 173793832 816398203 858796037 574503670 139980722 897234642 898974644 430967984 910537547 887333778 887422115 821237674 211514667 384900094 299762951 42793949 110709373 455281254 284699093 499660373 83172399 278341373 160010130 93831886 512908106 816878175 287856706 252733413 755293482 508024542 333873983 330832690 372113…
Output: 134529473589

Example 2:

Input: 509 65 139046635 133361129 903356695 902847043 51760301 791232891 932586025 113227166 555299460 855249700 782323728 671117561 583898924 357565496 833470083 953089198 739919953 477006825 824952215 584792670 878386506 895572051 796271717 329300403 8300668 636219837 561357364 422680241 33474433 378066286 499979937 7226778 32424531 611663178 126389162 393395278 576403359 524303611 786566206 615103767 903270223 548417454 647151958 276289383 190499825 529223419 430591872 644532945 349077968 953379182 288926471 137733993 747303347 777587065 490207531 904895220 213096104 166949014 3438618 758506330 694977807 847811088 284362749 9180913 417812880 737830089 242761075 954235 399400128 22874584 703128668 569463590 138156859 596156784 422937293 851969457 330597393 512064916 310089900 494005000 53570836…
Output: 37159404290

Example 3:

Input: 2720 569 506229508 327402095 36234286 403942890 845571058 712420733 913008 385366093 883280897 494881093 113753440 273342228 267607511 260275084 419582448 963404869 454916286 636729768 265398977 145613385 536778533 635299291 564763842 512774330 120780810 246835313 992667733 984956121 10301212 493787858 575810251 169296824 629875766 992156839 99696887 663468975 608527926 100543163 46746738 426699750 512783184 259002194 466936198 451103822 452967242 142320908 206446409 93932679 501922013 562000351 630003235 405470709 958495690 525540606 389746367 467545676 684702895 606953159 860642464 744006244 407519096 898183511 651392044 518231657 720102885 527812845 291103080 93069687 467594316 931418480 481616132 748852591 888295857 529582677 939516198 790299491 705982068 371087092 98278172 632586207 4…
Output: 301307282475

Constraints:

1 <= k <= n <= 3267; 0 <= a[i] <= 1000000000.

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