CT34813

Lakshya Counts the panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the silver mines of Lodebarrow, someone must schedule the next expedition. This year the task falls to Lakshya, armed only with the panels register. 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 <= 2807; 1 <= a[i] <= 1000.

Example 1:

Input: 2402 1821 496 82 652 33 816 35 148 968 486 413 617 469 852 949 816 876 378 917 972 940 842 56 591 40 4 681 123 726 343 943 918 641 539 478 514 240 949 812 587 67 951 495 298 35 792 298 249 832 984 273 655 471 62 570 538 163 440 429 284 702 26 747 461 298 872 697 820 389 780 38 267 840 894 127 247 718 467 653 237 727 401 706 474 227 296 189 987 221 927 509 133 27 766 894 932 880 624 248 589 594 159 424 454 169 990 764 231 820 227 872 978 785 452 343 148 930 474 268 567 132 684 685 851 217 284 53 44 894 2 43 45 460 272 39 763 404 293 400 864 731 335 958 742 982 529 227 621 929 720 91 680 774 296 804 228 431 625 444 252 447 403 334 534 24 825 124 552 205 835 815 966 754 396 54 155 123 678 554 871 886 342 701 588 626 725 631 458 98 97 846 883 927 529 461 300 243 66 819 916 773 281 503 621 825 …
Output: 942178

Example 2:

Input: 2667 1399 147 988 388 496 973 400 74 531 608 697 581 555 554 136 894 669 52 372 117 815 658 635 383 80 263 102 519 828 100 628 823 445 576 3 363 155 398 647 641 511 652 627 144 479 527 52 712 398 492 399 914 368 799 90 380 750 924 936 514 680 238 240 553 269 925 348 583 884 50 6 629 232 955 231 759 831 490 905 645 851 438 656 737 320 851 714 7 619 722 36 354 524 295 577 2 421 762 604 601 936 636 687 88 176 932 39 712 128 833 563 858 689 663 643 492 33 355 738 443 899 763 765 350 959 386 689 546 87 528 713 919 196 644 781 313 703 958 677 214 197 867 148 857 74 735 952 716 599 458 371 689 985 959 257 740 178 800 178 259 354 210 574 310 217 485 244 320 494 129 21 904 457 235 277 211 630 243 764 640 514 565 165 879 214 577 817 32 214 789 83 89 903 63 131 345 881 685 426 600 28 968 403 182 105 …
Output: 719770

Example 3:

Input: 1671 535 121 304 345 475 411 966 142 993 657 550 498 23 82 76 830 421 944 101 925 884 244 476 185 317 848 361 907 833 168 491 389 802 523 823 436 150 999 669 696 634 575 957 329 750 747 527 181 773 482 774 692 236 99 466 705 169 393 430 345 16 659 486 256 194 157 979 471 326 390 933 42 787 439 813 142 861 497 746 491 516 652 212 264 97 543 582 500 593 204 945 851 94 717 82 567 947 290 509 539 58 299 612 503 670 718 614 189 440 724 521 486 200 259 814 420 581 667 316 30 664 855 223 103 270 116 404 374 242 5 432 350 797 722 352 340 966 792 715 411 994 493 29 366 649 613 227 279 823 7 86 945 801 405 647 277 667 914 174 11 368 112 639 382 625 5 647 410 949 329 351 97 175 854 931 399 418 13 98 46 962 175 804 65 701 794 257 69 968 406 155 241 216 411 199 507 305 345 542 124 773 309 715 31 725 62…
Output: 279114

Constraints:

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

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