CT45198

The Fixed Window Peak of the Windward scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Lakshya the assayer watches over the orchard lands of Applerun's stores of scrolls. A careful computation stands between order and chaos. 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 <= 2324; 1 <= a[i] <= 1000.

Example 1:

Input: 289 1 468 708 404 397 731 274 219 707 760 244 777 349 197 476 741 463 584 873 276 869 869 799 446 121 352 616 96 601 413 741 468 503 513 356 16 18 170 284 507 495 334 155 984 470 737 659 907 337 592 88 534 448 299 771 717 658 58 360 323 34 81 893 37 656 292 273 817 558 597 685 289 516 633 714 934 243 746 903 322 829 690 832 932 607 448 742 513 31 914 199 130 656 284 167 296 98 398 506 799 720 233 184 465 507 554 492 783 852 75 980 807 959 651 725 740 208 310 630 807 96 110 541 115 949 311 473 837 317 441 732 274 733 544 606 935 452 392 690 629 795 897 301 717 935 738 390 130 327 34 132 650 99 220 143 814 543 918 735 954 177 783 269 655 356 187 845 846 879 54 571 629 227 978 741 834 783 110 621 724 391 961 430 885 829 887 282 629 265 537 201 482 496 801 80 962 765 920 523 595 302 694 287 86…
Output: 984

Example 2:

Input: 1444 19 645 151 787 850 518 942 793 556 387 315 337 491 494 967 169 609 47 526 236 666 475 309 686 751 785 109 943 656 858 32 945 841 629 466 675 916 542 360 620 499 187 318 828 865 753 805 612 55 669 49 921 219 539 972 679 39 313 502 895 557 901 544 518 690 340 194 803 219 985 448 22 541 662 697 547 780 715 852 912 270 775 168 754 860 784 498 409 249 293 690 804 739 758 176 304 990 747 68 595 864 983 763 876 261 163 870 201 254 792 403 984 431 799 889 81 206 149 706 974 248 401 446 514 743 484 762 905 791 868 241 807 968 194 564 583 814 715 336 837 499 769 388 342 859 888 197 417 474 274 139 359 84 917 865 26 876 641 776 995 694 947 876 491 274 796 808 273 921 623 204 377 848 410 367 93 960 462 897 12 603 471 766 172 371 475 158 942 819 12 523 831 965 503 21 602 681 568 448 101 139 641 82…
Output: 13487

Example 3:

Input: 980 961 816 701 577 613 570 119 144 711 956 892 989 298 231 459 774 439 847 357 699 464 348 760 771 656 429 760 412 924 36 124 56 28 399 757 559 90 395 844 207 565 791 666 551 369 450 559 894 485 401 29 504 110 641 820 888 608 273 651 472 679 391 746 933 735 72 413 455 598 850 741 74 846 196 514 116 12 335 753 629 426 702 203 884 743 212 323 199 427 447 493 5 686 598 942 552 507 652 95 424 552 311 289 780 271 727 517 443 48 512 942 80 804 713 764 189 440 228 523 211 418 749 281 374 215 609 630 298 690 402 723 77 820 551 896 809 230 201 753 934 823 836 134 938 148 866 315 212 97 520 180 303 536 176 475 911 930 45 307 632 686 585 949 688 726 460 713 102 324 842 895 504 878 221 970 111 71 498 307 591 227 666 113 703 270 181 644 13 492 514 561 52 315 50 342 30 79 892 245 194 505 818 692 583 71…
Output: 477187

Constraints:

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

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