CT34003

The Highreach Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The dispatch writer Manav has been asked to audit the season's records. On the desk lies a long table of windows readings. 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 <= 1495; 1 <= a[i] <= 1000.

Example 1:

Input: 1258 679 693 848 440 256 639 143 113 941 34 177 874 560 287 92 235 934 169 683 327 117 817 651 520 344 75 72 623 110 301 614 873 759 86 228 674 37 262 781 719 627 935 860 703 267 198 800 937 126 491 634 834 420 41 906 788 106 618 892 511 410 247 143 843 226 135 714 596 374 987 462 687 701 812 167 585 472 458 634 793 738 210 878 779 451 229 727 543 613 805 974 472 229 354 185 736 251 825 656 641 999 424 572 599 254 100 445 210 473 606 521 652 203 334 560 392 854 364 876 948 810 939 983 328 654 30 531 523 259 567 536 369 721 246 885 196 819 432 479 378 478 823 605 402 15 777 411 723 180 64 450 544 26 612 992 781 495 229 126 827 690 141 473 356 254 802 697 501 352 555 149 891 643 457 874 124 817 654 116 22 751 1000 473 796 172 764 807 774 822 350 768 307 644 800 377 400 738 702 774 271 714 90…
Output: 346740

Example 2:

Input: 429 57 830 459 872 134 869 288 239 879 133 234 178 872 678 410 284 732 748 776 528 225 326 945 101 523 728 158 773 525 296 397 483 64 329 603 453 13 230 656 116 159 2 906 327 135 829 723 943 983 345 564 631 938 244 247 775 424 134 129 348 629 517 646 214 28 582 547 56 865 967 557 350 159 881 838 880 106 344 754 134 335 494 409 164 720 601 701 450 554 850 509 647 751 733 58 200 4 402 792 294 463 80 161 784 465 141 347 153 241 230 866 172 717 704 134 29 658 690 567 115 854 6 414 995 68 968 861 654 745 248 280 338 899 424 74 111 300 984 271 723 699 729 425 118 486 648 236 135 82 505 636 592 487 566 61 507 166 965 77 839 771 186 163 191 540 522 838 475 522 158 211 467 879 922 114 457 110 479 379 255 835 834 989 5 555 588 409 362 300 485 692 635 749 942 54 776 19 467 159 677 880 94 43 246 862 5…
Output: 30855

Example 3:

Input: 1105 202 770 609 235 257 626 761 45 447 500 168 66 815 735 613 759 358 280 556 289 419 472 866 373 356 921 564 501 939 915 242 56 204 821 804 555 466 482 531 9 526 402 119 42 645 198 804 561 397 575 271 870 137 606 85 632 376 167 823 158 288 493 249 103 311 700 44 750 417 44 307 471 899 465 555 377 883 200 29 508 372 111 276 67 865 185 764 614 744 905 740 814 110 666 852 334 42 216 294 820 725 714 327 284 513 125 940 629 257 166 66 6 154 583 750 887 544 319 9 244 301 751 832 985 526 244 161 355 841 765 41 852 12 39 671 360 244 274 626 771 182 338 623 696 739 256 48 611 96 711 47 97 316 720 137 354 580 629 361 459 53 206 806 292 281 673 633 468 79 61 605 357 755 705 423 347 592 923 386 702 979 658 815 875 673 19 355 949 726 385 149 671 564 927 251 371 238 877 343 899 242 47 966 807 553 472 …
Output: 108346

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Highreach Fixed Window Peak - MEDIUM Coding Problem | CodeTikki