CT47126

Hema's segments Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the honeycomb cliffs of Beeswick, Hema studies rows of segments entries. One clean number will settle the guild's oldest argument. 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 <= 2372; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1608 328320200 615231 715444 26742 271007 187953 393467 608585 63872 568556 406933 229092 726394 231324 316982 973172 329276 345976 858705 757956 517660 362274 610596 246602 505597 175358 930200 910996 52172 989809 668176 645064 293787 914504 316893 638234 303549 239477 247515 662200 782752 413033 340289 4145 24636 183091 570494 545289 890278 505652 217447 447805 123947 271328 130515 597634 859898 964625 825379 615305 498024 358825 415959 707527 313683 188740 96708 464943 843344 716185 220760 469956 573083 398187 84492 408599 594152 587043 12694 67317 770365 476414 674576 861022 633275 862246 138106 125391 93758 419499 690927 813649 276574 20786 169755 23681 607781 233679 680833 324485 419906 17380 74916 33078 149277 945053 901923 886198 187801 939362 61469 405922 7504 633092 450511 369581…
Output: 627

Example 2:

Input: 1629 28342792 607880 956105 685302 113258 109779 359505 379348 960527 937972 981530 93432 15682 945182 388496 197376 489062 664085 572710 683646 926589 219427 125511 413054 856676 266334 209630 922678 446179 355633 361164 281073 957006 446707 214929 40093 784056 132420 13272 522172 945076 5542 657885 944386 268923 433519 985400 400508 711867 683698 682347 348983 901175 930988 157956 293937 758401 759651 656988 1911 718141 628086 808841 667470 511026 957282 283322 204196 975315 855568 175395 945540 446199 26772 870204 14224 697315 342905 504477 640659 740273 294577 439647 643383 715775 547460 401008 52248 715830 188762 493805 651001 436599 64776 908580 765203 387951 977137 97381 435063 930994 656926 748979 105189 137488 569885 791551 892638 22903 689370 58952 754095 819484 380064 418257 651…
Output: 48

Example 3:

Input: 2001 705578851 400046 814696 761533 491757 889536 44330 230246 338449 630831 52265 224355 126989 977199 287911 982226 836661 119917 708698 722147 633610 777203 243230 777178 221539 23802 856106 529995 783150 294492 335341 893605 704525 355818 740500 454558 316714 569990 540881 49670 250354 867593 510907 891867 908356 194396 222226 361915 775039 731660 492135 543120 154304 402119 406083 341595 202407 260379 97408 642824 929132 112694 503707 874344 695409 701418 285391 391295 403689 127654 290589 711794 265888 397381 498161 843127 210553 848690 674001 995333 893758 713715 295345 724922 385547 304144 408804 559599 518536 765620 349376 47071 356339 656531 548052 628631 936458 55115 214071 993545 130524 857848 103278 244307 942149 132051 182312 359119 139053 560843 663196 948955 803631 698799 3…
Output: 1343

Constraints:

1 <= n <= 2372; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
Hema's segments Tightest Stretch - MEDIUM Coding Problem | CodeTikki