CT30821

Last scrolls of Manav

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the monsoon port of Rainhaven. Manav spreads the scrolls records across the table and picks up a sharp pencil. 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 <= 1899; 1 <= a[i] <= 1000.

Example 1:

Input: 1044 59 456 530 428 236 424 362 278 192 50 738 747 10 494 827 961 544 434 908 579 212 934 304 9 843 269 320 952 474 595 307 777 162 901 978 460 612 100 406 110 370 760 313 139 838 460 728 990 251 196 398 360 372 889 454 919 637 507 436 637 926 801 845 679 260 852 564 684 865 458 599 618 810 824 620 850 480 383 77 100 415 109 945 894 296 349 142 779 132 905 761 552 616 269 243 471 693 903 705 842 312 677 609 853 844 29 482 83 8 382 30 400 57 599 41 835 636 502 130 483 307 161 487 66 591 280 396 181 351 563 104 438 329 959 540 10 187 922 637 22 135 842 124 972 590 937 260 967 961 959 515 56 351 323 92 501 941 334 419 755 761 175 804 470 90 79 732 443 587 158 478 871 549 207 189 559 637 689 869 317 406 394 72 493 599 731 157 112 16 378 271 38 294 976 407 770 185 113 574 719 570 375 502 746 14…
Output: 34385

Example 2:

Input: 1785 96 730 838 342 933 844 743 233 874 832 6 692 178 700 624 1000 396 491 735 515 694 980 179 221 129 721 599 160 322 234 283 465 231 941 392 18 640 324 795 711 983 213 281 145 819 644 259 486 574 256 437 730 662 981 209 461 334 907 77 861 792 819 117 679 620 522 230 565 901 356 92 212 9 237 608 790 798 494 116 578 511 11 724 903 667 235 815 630 77 24 43 922 902 318 17 77 312 526 786 358 294 751 338 525 529 261 290 386 821 95 276 69 31 536 236 413 223 813 512 630 732 183 285 389 179 917 84 483 980 187 491 557 934 502 777 765 911 928 25 168 683 469 754 922 126 95 440 556 978 197 931 389 252 571 472 122 872 52 691 59 62 94 552 328 22 389 294 124 9 515 211 834 451 772 502 422 971 645 983 853 232 522 362 425 827 361 566 459 51 320 86 617 281 993 919 888 410 506 957 203 105 521 269 537 66 715 …
Output: 55754

Example 3:

Input: 918 312 689 899 109 243 929 566 416 195 41 775 853 744 310 667 958 389 100 398 30 153 434 378 63 691 232 340 289 598 570 261 221 388 803 478 954 792 390 373 955 974 146 172 471 989 841 257 606 325 828 731 201 438 235 956 495 283 505 428 707 976 362 297 184 939 741 70 443 781 960 319 497 646 727 846 162 232 236 273 439 898 617 581 402 854 692 1 476 920 366 877 391 110 760 218 639 641 30 412 684 371 310 947 897 29 788 763 207 438 132 860 567 466 580 486 904 277 442 129 195 608 289 615 225 730 989 769 25 729 927 905 760 775 345 243 530 839 440 576 385 11 409 816 667 646 372 597 6 550 473 575 838 635 96 980 243 408 789 677 404 917 787 533 483 277 477 3 730 969 495 454 809 175 18 993 131 127 604 886 901 686 176 660 787 907 250 295 144 376 796 941 714 650 425 310 635 419 845 18 963 591 88 94 333…
Output: 169383

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last scrolls of Manav - MEDIUM Coding Problem | CodeTikki