CT31791

Qadir's Solar stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the ferry landing of Crosswater; Qadir weighs the day's stretches 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 <= 2456; 0 <= a[i] <= 1000.

Example 1:

Input: 1592 1344 511 414 829 784 888 901 435 127 987 697 24 912 710 44 586 429 941 715 882 481 171 772 104 613 568 125 812 654 678 395 76 130 540 610 31 500 153 684 336 363 867 356 458 977 243 496 682 924 3 707 52 780 421 112 844 802 795 450 510 450 521 586 247 127 729 508 921 841 127 455 814 830 331 940 726 541 922 110 854 255 264 972 325 993 394 569 391 208 590 573 809 856 824 989 412 191 925 194 968 350 249 993 863 316 583 822 625 977 686 282 881 380 343 834 682 686 21 107 388 860 199 400 42 572 20 638 252 607 377 282 953 691 386 698 233 169 122 51 957 845 990 18 817 809 945 134 369 126 895 947 622 156 280 701 688 351 430 933 891 299 409 859 131 387 84 674 441 528 459 908 748 791 908 739 511 556 133 233 155 686 477 140 249 546 556 629 323 501 835 220 991 137 79 722 683 755 771 334 701 66 218 4…
Output: 684607

Example 2:

Input: 763 182 496 97 929 884 42 169 863 699 229 388 766 870 438 915 268 27 309 813 219 778 626 409 655 246 959 891 958 912 191 881 300 751 644 796 493 485 972 900 992 160 819 762 519 172 504 797 691 487 386 880 308 305 500 808 806 644 604 769 549 612 729 479 98 1000 734 174 977 542 205 723 119 449 180 890 10 98 550 498 103 487 626 294 25 436 86 936 141 345 190 826 194 710 192 920 615 870 500 427 367 317 183 472 718 83 554 788 568 559 196 247 663 0 799 341 205 307 990 833 904 39 490 583 200 28 69 85 189 487 518 141 18 770 12 359 355 776 591 235 924 239 404 230 535 523 268 242 591 319 291 225 922 233 221 348 701 978 165 865 649 654 42 365 666 513 78 43 752 651 640 414 839 393 726 567 514 721 303 796 140 149 98 224 293 228 677 342 343 385 107 280 725 563 100 77 673 496 260 186 98 639 699 74 311 162…
Output: 94146

Example 3:

Input: 1534 903 402 394 72 97 933 9 49 157 769 413 937 645 160 208 148 585 556 639 97 923 674 633 179 633 644 688 911 506 723 182 642 664 14 247 785 687 315 733 652 666 305 392 502 309 115 661 375 398 484 319 534 107 478 728 138 649 424 210 387 598 887 363 487 581 938 963 835 156 305 278 653 19 843 552 597 674 798 519 977 313 602 906 123 701 504 400 743 911 347 28 794 559 652 797 762 408 913 139 619 558 248 572 506 514 121 388 403 122 939 130 525 141 456 943 291 994 405 262 858 493 315 505 655 344 756 784 492 88 530 84 422 123 705 7 612 482 523 334 111 883 238 593 204 476 282 296 521 162 310 233 627 39 450 607 903 299 766 138 372 480 642 246 787 297 162 661 704 747 208 335 926 595 622 790 380 52 934 44 559 526 601 830 57 352 831 257 61 40 209 747 659 879 626 753 15 520 667 40 897 688 32 347 921 2…
Output: 453156

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Qadir's Solar stretches - MEDIUM Coding Problem | CodeTikki