CT33627

Dorian's stretches Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the bamboo terraces of Verdantstep with crates of stretches, and Dorian the auditor must account for every last one. 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 <= 1299; 1 <= a[i] <= 1000000.

Example 1:

Input: 204 145 854587 649602 756430 912485 364753 351245 425480 812404 815424 519306 171031 560244 924068 150081 130335 58426 300835 852753 712975 715381 753159 636064 168611 641505 966921 845465 935006 746212 425419 114358 951948 260093 665211 159663 428202 118247 732952 194312 23287 837961 269770 207937 962159 658524 372749 858780 82267 623973 250131 357124 273335 726357 736006 336719 876399 540105 138500 755352 44224 18522 481954 102908 782185 961845 549649 594847 413621 320890 747994 547289 553420 969086 950207 495685 134637 513896 831904 551136 58058 253221 564992 497109 726150 163870 286709 133943 589121 406423 328652 623397 962258 332749 735975 58014 332899 505413 83069 48846 633052 941030 275841 914515 948215 773155 341332 637074 735663 854261 824563 548740 950461 459195 905820 269969 747…
Output: 76627466

Example 2:

Input: 558 108 266521 685811 631131 782258 869902 761637 219022 174100 81996 601209 892140 464354 920530 193825 995010 983599 615776 828582 815775 306659 878055 874003 386930 961258 581720 740496 403610 796338 139769 319987 278511 475453 318113 572698 577506 514798 544733 112910 614025 35166 284793 419738 984177 693950 415102 973814 953194 227440 359256 943674 450676 588648 637115 541840 600788 289515 13265 122005 252962 95751 944359 392456 950826 142913 519098 847643 382860 44540 111923 368070 99104 192762 32789 53271 189026 703217 892997 482046 24207 318955 505898 875777 984990 348651 568068 149268 755023 614788 627461 863524 523727 32055 18361 366386 419784 207166 491748 953765 968487 169446 133751 930649 29959 245448 730542 988711 784917 882268 333574 75566 767481 663594 55409 384303 983076 2…
Output: 58481467

Example 3:

Input: 404 260 322964 646684 361308 168654 790141 393781 347445 164963 200752 723028 31407 563486 786118 28981 511208 53511 449004 911687 373767 975256 596636 739560 780649 634490 282939 60796 967493 301941 180854 401341 556468 185043 283018 209903 407961 490468 135241 866338 404645 604649 278758 254674 882610 713806 206139 750428 265940 359055 928049 587809 535526 289541 633018 165668 507246 701575 171420 358193 812858 590970 590633 826728 894884 374644 117277 830233 595970 310255 870221 23038 789959 471992 536201 118662 99071 463602 703307 354464 2815 824560 537511 314785 587826 813307 269089 342451 485015 336221 223012 574287 473873 10396 538102 954305 557370 968033 982469 742347 177895 181811 655251 359856 517336 926351 286784 414489 582767 42515 853205 729992 217189 479039 370473 292800 2546…
Output: 132413763

Constraints:

1 <= k <= n <= 1299; 1 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.