CT47263

Zia and the Fixed Window Peak

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the marble forum of Argentium; Zia weighs the day's windows manifests and starts the calculations. 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 <= 2849; 0 <= a[i] <= 1000.

Example 1:

Input: 652 596 57 291 628 51 656 745 435 817 172 599 480 598 165 354 348 390 423 528 800 49 793 320 607 104 312 680 577 783 286 931 694 705 789 177 564 691 966 675 503 694 39 13 702 887 959 739 529 713 125 663 658 856 237 91 334 36 595 591 346 1000 147 10 21 900 40 211 986 974 153 673 135 219 726 8 592 675 176 140 231 948 771 665 435 547 477 19 19 620 556 530 333 611 334 492 375 716 802 233 329 246 509 688 405 839 137 232 310 185 249 256 984 122 80 377 165 511 636 617 221 283 473 557 615 322 837 356 303 457 461 691 330 531 71 505 179 937 785 267 685 866 570 14 550 403 227 440 548 166 254 594 539 958 946 476 397 274 637 414 951 175 376 953 791 441 309 479 956 678 369 906 594 330 476 569 391 461 556 459 250 935 735 560 487 105 901 671 474 99 54 258 2 591 883 587 827 272 401 360 72 129 206 410 598 6…
Output: 293942

Example 2:

Input: 1691 592 529 699 0 713 97 620 250 78 485 960 410 333 168 405 629 587 178 89 954 805 720 635 876 641 282 415 93 527 84 235 359 304 386 580 499 902 71 602 11 886 671 424 401 500 880 496 480 346 56 61 46 695 806 757 345 377 573 976 55 187 321 78 341 882 70 800 57 698 804 103 387 657 893 125 372 821 588 286 801 646 847 556 657 949 257 197 960 574 651 681 344 94 611 82 617 919 899 103 559 257 683 773 177 152 140 291 273 510 359 373 697 867 18 20 333 484 417 66 883 740 574 494 214 199 42 270 570 265 629 381 355 208 340 401 972 901 432 668 45 458 686 584 954 902 301 424 731 141 481 259 308 80 557 30 850 281 694 955 472 954 290 687 627 307 233 772 784 451 154 954 238 928 405 821 950 506 844 242 781 118 426 925 318 867 84 93 501 787 883 102 800 878 813 867 869 68 895 358 728 711 195 542 117 752 379…
Output: 306827

Example 3:

Input: 918 774 599 75 745 953 0 768 288 428 175 3 17 685 243 187 171 639 675 985 64 110 601 763 827 680 83 469 895 933 980 285 305 69 243 273 838 846 386 646 680 383 643 645 909 545 850 341 604 490 337 116 470 765 45 713 546 945 609 79 173 792 192 696 408 780 572 154 983 811 732 243 728 449 910 528 978 376 713 590 531 862 757 783 54 649 83 744 31 422 539 28 84 94 25 936 270 47 290 522 756 680 981 144 605 895 161 144 866 451 430 894 98 400 601 335 260 538 923 187 599 455 901 259 90 740 754 120 507 535 613 869 25 774 676 524 101 327 290 11 193 717 475 119 144 154 607 380 396 593 228 177 288 163 575 157 902 112 171 68 787 646 223 309 910 923 826 838 635 856 717 21 37 880 752 8 961 437 216 270 994 206 978 541 390 43 721 915 26 296 646 583 594 115 763 896 344 440 780 978 384 930 529 155 514 483 877 54…
Output: 393688

Constraints:

1 <= k <= n <= 2849; 0 <= a[i] <= 1000.

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