CT56357

Jatin Counts the windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the frontier camp of Duskwood as Jatin unrolls the day's manifest of windows. The tally will decide the next shipment. 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 <= 2431; 0 <= a[i] <= 1000.

Example 1:

Input: 1940 1916 534 595 982 648 555 320 188 522 755 855 816 377 353 583 419 532 512 179 293 715 320 968 599 853 92 641 327 609 753 549 986 35 654 997 647 852 248 758 876 181 36 223 882 920 533 993 516 59 532 737 11 787 72 26 116 68 354 299 949 577 75 243 84 993 419 187 329 927 743 397 369 356 507 80 965 100 175 671 640 198 547 71 390 988 271 623 692 604 934 450 180 710 809 660 78 3 547 127 526 527 361 336 229 26 29 810 260 784 377 215 236 286 231 326 373 285 751 402 380 665 889 82 41 884 173 498 795 569 441 494 444 266 739 192 997 263 577 594 794 168 123 564 530 956 793 228 218 91 688 884 385 986 8 635 922 656 541 642 771 567 609 239 950 723 860 240 635 344 198 975 203 115 318 828 650 777 957 213 292 354 621 513 433 209 180 663 782 815 188 321 839 717 979 2 277 965 251 283 282 568 370 938 310 56…
Output: 957905

Example 2:

Input: 1837 1539 792 96 913 133 737 564 610 397 428 656 409 790 53 971 688 509 59 455 78 708 309 433 165 573 514 760 320 525 282 599 447 302 754 767 606 52 356 434 673 428 753 4 48 477 498 798 603 857 954 591 914 954 405 583 891 693 131 930 40 468 375 270 669 762 125 323 223 987 360 400 748 665 771 728 876 709 264 27 772 142 386 691 496 816 943 185 700 563 209 22 684 509 606 768 196 538 517 679 252 155 175 392 934 66 819 529 133 120 335 291 900 178 719 102 199 840 79 146 373 688 481 895 767 344 528 372 170 314 987 542 34 451 896 622 710 340 409 971 759 746 315 450 52 418 885 952 76 666 672 898 127 620 117 461 947 621 998 204 954 995 335 934 547 783 26 431 444 380 447 539 713 228 101 230 491 602 516 138 534 718 210 154 427 630 474 451 768 856 790 247 128 633 845 337 37 919 134 640 585 140 337 269 …
Output: 776395

Example 3:

Input: 2422 1626 839 152 218 102 123 15 787 778 321 658 708 833 792 128 104 653 503 419 152 136 469 491 480 212 468 407 14 21 632 794 668 252 328 356 341 307 162 994 646 630 903 890 772 857 483 823 617 895 770 997 142 816 409 516 314 111 28 182 252 379 66 728 377 286 736 518 660 37 47 502 250 32 450 757 750 102 650 847 601 899 957 537 256 504 118 799 189 410 544 810 852 25 410 97 38 625 628 748 680 779 969 144 469 376 335 991 554 680 229 470 976 204 140 185 422 176 605 44 901 816 494 356 491 606 32 64 117 242 930 705 292 889 871 827 555 192 402 158 155 636 84 335 627 108 193 375 956 92 208 929 261 48 824 667 643 641 778 580 126 154 539 631 265 56 715 621 434 907 674 510 591 950 595 793 492 110 181 708 995 68 280 1 394 670 211 902 373 452 364 223 691 672 570 485 541 947 959 404 649 918 221 98 744 …
Output: 822007

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jatin Counts the windows - MEDIUM Coding Problem | CodeTikki