CT34531

Last segments of Sara

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the quartz ridge of Glimmerfell with crates of segments, and Sara the cartographer must account for every last one. Task: Print the minimum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the minimum window sum. Constraints: 1 <= k <= n <= 3603; 0 <= a[i] <= 1000.

Example 1:

Input: 664 662 220 803 201 745 70 704 494 220 214 492 462 861 969 825 355 327 332 165 876 258 192 738 93 72 229 742 855 10 301 656 658 548 481 475 917 545 919 243 665 636 448 551 423 732 376 982 27 131 798 693 652 854 178 459 436 255 90 639 703 978 649 643 228 446 415 192 282 666 231 564 459 900 53 59 708 97 921 817 585 629 208 176 680 433 21 22 225 973 826 744 780 44 78 145 227 570 173 158 237 885 725 600 715 104 569 442 353 257 432 4 731 963 828 483 909 386 154 156 111 869 386 278 823 158 710 729 665 975 163 851 836 931 225 900 873 537 750 464 499 435 420 292 109 67 746 953 990 15 21 525 787 736 363 442 960 96 486 670 563 609 895 911 840 487 251 219 945 0 811 289 447 257 573 965 548 988 967 516 349 525 649 993 559 291 416 588 371 774 129 370 354 648 721 770 805 218 808 675 357 266 518 320 595 6…
Output: 331945

Example 2:

Input: 785 391 563 925 8 143 706 317 36 273 340 705 454 421 355 580 902 858 947 139 651 764 424 400 164 141 447 861 346 762 694 378 218 742 467 604 864 806 295 448 579 671 99 522 633 454 905 75 491 963 234 279 281 20 286 926 992 232 817 812 224 650 604 738 29 757 727 770 972 573 989 824 256 679 257 59 508 30 649 512 446 771 207 209 324 124 114 170 602 968 775 388 176 857 538 573 122 490 574 220 855 909 796 795 322 82 351 25 296 539 657 19 503 470 769 965 715 672 679 19 348 901 330 697 571 538 38 710 617 734 714 922 509 396 275 215 902 442 822 466 507 649 814 396 940 567 888 254 702 502 931 321 720 436 102 68 857 950 791 578 432 993 702 671 67 507 573 111 410 533 777 613 387 557 343 622 993 898 818 143 387 193 557 409 272 670 416 549 822 48 877 229 673 884 787 987 940 166 273 630 778 813 849 451 4…
Output: 193853

Example 3:

Input: 1381 774 928 494 561 211 306 507 853 309 190 57 838 219 838 527 565 499 223 470 525 637 715 590 124 957 517 240 756 329 304 828 13 636 435 474 43 303 180 143 126 315 108 7 892 596 35 267 721 864 285 459 732 652 537 755 224 77 893 185 950 609 666 27 585 3 532 457 133 656 28 419 831 270 487 85 498 919 935 81 87 956 217 556 877 191 311 25 36 20 992 315 13 772 630 3 323 494 200 205 432 636 645 992 619 342 118 233 936 987 923 894 971 319 320 265 489 87 430 839 762 489 105 444 688 974 451 203 764 558 206 741 882 695 917 883 88 448 242 457 856 717 566 360 837 768 949 795 442 562 415 11 225 36 482 260 414 189 644 262 217 113 334 354 264 190 925 752 665 831 910 157 687 263 117 591 929 166 341 366 795 146 979 771 484 816 545 355 860 479 746 612 444 942 656 801 911 234 649 812 668 861 217 797 547 375…
Output: 376029

Constraints:

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

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