CT40098

The Azure segments of Lakshya

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Lakshya inherited the dairy at the tulip beds of Bloomhaven along with its curious bookkeeping system for segments. Time to make sense of it. Task: All values are positive. Print the length of the shortest contiguous subarray whose sum is at least s, or 0 if none. Input format: First line: n and s. Second line: n positive integers. Output format: Print the minimum length, or 0 if impossible. Constraints: 1 <= n <= 1843; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1013 61032366593 80328083 213791413 979263628 582319340 586220617 943337936 431014717 513408993 406815766 331464008 639774455 981339443 668395200 693420061 799967767 649143118 309020638 481522094 351521344 905625830 146649188 797344754 841262882 974138593 430292156 715778349 446088443 114150797 842334421 407674954 965126503 945733432 8020072 591223019 451110694 896613634 699554358 617063006 814073293 409874425 757029038 456922302 610556120 26674999 184486633 959414929 848068640 339096483 42581760 496123176 25190170 573649660 498793406 268632543 958980255 851124084 713808916 297441447 899150204 681826181 982078236 6021042 466974520 642142004 943795368 32918221 189548453 952511840 359982698 85020092 571455830 249476687 195780700 128710526 838416614 36994544 701952679 222701473 669269459 4004…
Output: 110

Example 2:

Input: 379 65154321919 671081154 524591349 307288313 72405160 171073184 117091236 891919947 656477113 722268743 554314844 275453380 744809175 910634639 345670314 579833121 541460435 178802402 546177455 110456801 57725150 288777633 60570086 160048346 336852906 992853199 302851180 233152484 727013546 99811252 105306551 403497592 180362708 3715047 580224488 856589270 575573102 565925745 963375726 176179357 954621188 778696178 204386433 23287432 556377930 993885453 28989953 93478451 981384556 277696320 617586201 602506915 278757328 969938342 406832782 11615488 194385082 625292310 986415564 241637017 313719006 883623030 930930707 886435736 497457035 473509245 343378425 775601152 580373827 198248193 522112459 202102127 172333683 355396813 784270859 482785084 27884544 360537222 55360969 746364164 260553…
Output: 118

Example 3:

Input: 21 2176388121 828173562 654724906 402219097 731746010 153988165 951455264 100276476 443117012 828142453 414755448 409900566 94225583 989655705 426162003 909987331 214945657 602155503 432014062 986584484 507981998 657246258
Output: 3

Constraints:

1 <= n <= 1843; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
The Azure segments of Lakshya - MEDIUM Coding Problem | CodeTikki