CT29348

Yash and the Jade panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the seal rocks of Barking Cove; Yash weighs the day's panels manifests and starts the calculations. 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 <= 1566; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 452 182 390589 691816 18152 -307815 158078 888772 12700 874054 915117 -998725 139601 489511 -185848 133382 856234 37264 956395 -358632 531403 782280 -197020 -62140 -554505 -118620 713150 31592 172368 901748 192263 514670 508806 309273 -414923 -338368 -554289 302382 971120 878881 348604 -976607 -628021 567361 290726 -187333 -604975 -323392 -738653 -13375 797062 -895502 -390025 -249991 -614364 815275 273144 671915 205943 -786501 108213 -766582 288322 755964 -394287 -712292 -220387 350849 -593992 -723501 797453 -789937 -561536 -332121 667703 377366 -913672 125475 124462 -204925 -52909 267428 456700 -263457 893227 -973197 496987 607798 -124883 -976690 -651122 992298 -372027 277783 863739 632469 654880 -553331 684776 -323881 992972 469461 68108 744083 -559062 849611 -821203 -316843 -679786 -225…
Output: 13104480

Example 2:

Input: 358 184 -693104 -853623 439520 -952180 302887 -4805 548311 -591651 -246433 962089 -476023 -972287 -99430 -502704 -916495 315295 525606 748025 641612 639821 -420427 662785 -471650 969871 -378253 985031 -62820 -186413 406622 -153961 563222 416444 790538 -632291 -775576 900513 312845 -983906 227115 445437 543593 349947 -352674 -228044 -10177 -548475 692991 910028 -758515 403925 256721 799173 -933237 657511 358898 978094 -311827 -937915 -344019 375394 -104061 -47932 -244087 890834 821766 350851 -325493 -827857 -932764 -941800 -157785 641189 -317183 -248251 408988 -943199 -986550 286488 -862330 -891580 791265 -330074 -141804 -931687 -969399 816088 -294244 110023 287748 260069 -880046 233745 -15841 160823 189741 -223695 -954699 892028 -321778 -150824 819793 -278735 -782630 -929920 -938131 28923 …
Output: 15685622

Example 3:

Input: 908 380 819307 -280709 -137612 657082 870303 901937 527244 760237 781459 -104325 498796 94364 622469 383160 400965 -37857 -778573 -436968 -905398 603578 -500201 -16966 72628 -665035 823303 -982468 -964359 401618 908905 572009 239946 -286079 -139699 -667945 -305699 937458 -870235 -788782 903705 -708203 -254387 -465600 243167 397094 -227839 -856237 874406 -567857 418525 762256 831974 756667 452943 217534 -163137 -242081 425809 642955 200263 -514847 -859224 -71370 -602500 953137 -846758 -12687 -876735 607316 705656 -439548 -144912 644234 268798 -570261 758514 580336 823184 -534077 -220848 685071 -616134 219323 356693 562577 -295665 757161 -203704 937533 -612524 -897228 -378258 452972 -957283 -508357 -317304 -852962 -803380 -279288 950277 285356 -752323 934441 474063 696705 -462227 -536806 -33…
Output: 20859936

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Yash and the Jade panels - MEDIUM Coding Problem | CodeTikki