CT35414

Sailor's Prismatic ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the spice bazaar of Saffronia, Sailor studies rows of ribbons 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 <= 3136; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Example 1:

Input: 1654 636311 401 897 403 464 777 979 793 197 439 556 454 938 563 854 116 95 409 294 902 106 352 8 849 15 32 111 583 977 172 432 296 908 50 25 549 904 700 561 159 969 545 471 496 482 780 249 465 81 876 346 224 269 429 746 252 597 518 151 947 855 55 478 482 175 202 275 710 765 359 240 603 723 695 69 398 317 369 153 626 759 707 575 718 74 617 988 837 813 734 210 567 808 36 54 588 267 981 86 749 719 543 622 32 160 166 157 218 218 839 330 520 778 559 98 222 132 999 459 969 644 886 829 472 717 466 626 185 133 804 312 558 791 128 120 107 277 340 640 873 606 284 967 862 796 113 158 586 651 355 645 60 750 208 13 9 185 817 892 568 283 281 26 576 924 319 346 42 669 864 245 144 287 153 210 991 746 813 669 239 703 944 787 508 622 223 430 140 251 848 486 540 676 950 327 641 578 798 446 173 319 483 935 73…
Output: 1274

Example 2:

Input: 425 4645 252 247 807 772 79 409 463 426 962 201 359 975 313 272 382 192 319 786 232 913 233 559 959 749 911 685 281 505 182 255 415 370 134 570 623 560 336 341 425 266 556 709 700 423 782 227 9 177 41 262 892 873 469 447 216 821 38 138 908 133 24 194 879 183 347 552 846 325 629 846 584 622 893 880 505 670 575 593 243 281 703 87 418 248 316 903 360 66 283 177 669 859 326 553 223 757 874 921 327 921 234 972 558 602 554 990 87 167 988 191 952 950 745 885 351 405 960 789 11 591 962 120 37 577 432 837 894 193 762 869 84 301 569 729 806 835 14 215 917 602 269 390 45 188 555 513 13 750 545 343 52 461 534 517 600 706 383 633 9 614 539 390 367 245 894 321 869 289 502 449 58 464 564 95 208 798 546 651 994 898 444 503 431 730 722 69 147 43 510 592 837 262 515 526 629 380 75 559 338 900 66 697 111 901…
Output: 6

Example 3:

Input: 1261 358207 873 348 795 929 263 793 169 936 419 611 383 269 196 486 407 119 220 723 280 484 440 925 580 429 121 883 918 15 92 382 227 236 19 30 965 710 818 985 884 236 939 12 491 977 684 313 264 135 359 223 98 223 337 665 725 525 225 585 241 14 170 175 294 198 36 836 151 677 581 265 851 631 119 385 438 394 76 923 505 967 429 894 695 205 134 319 276 292 650 758 330 558 198 176 145 35 847 330 162 60 216 555 574 810 784 19 342 893 970 244 696 657 913 620 84 450 382 387 709 528 131 210 326 356 413 256 200 817 859 178 877 165 907 585 17 37 541 128 136 50 254 620 295 967 728 173 546 387 291 994 201 538 76 269 38 285 448 419 616 53 987 920 832 539 443 23 607 158 8 359 214 812 245 894 738 487 483 749 9 463 656 68 46 938 453 566 950 633 112 300 685 481 323 404 87 488 431 128 395 672 262 92 879 639 …
Output: 705

Constraints:

1 <= n <= 3136; 1 <= a[i] <= 1000; 1 <= s <= 10^18.

Loading...
Test Cases:No test cases
No test cases available.
Sailor's Prismatic ribbons - MEDIUM Coding Problem | CodeTikki