CT38735

Seth's Ledger of ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the jade shrine of Serpentis. Seth spreads the ribbons records across the table and picks up a sharp pencil. 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 <= 1927; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 677 317942226 345692 473229 604655 661684 583675 155706 639105 209732 969383 457424 491671 575536 251164 232983 672416 214743 81907 971389 659867 737502 3486 194361 989001 362624 409575 67295 909667 118723 563955 602381 973769 989529 789618 336911 519864 306245 472406 531074 879255 633401 693456 316203 179500 646493 160174 283967 933910 53875 975608 238405 675617 754489 186517 92997 15205 335747 738027 67522 659555 112367 118456 588785 435755 522597 259458 775611 897973 364602 794126 79672 686540 421192 987951 408709 284676 326296 316182 996791 132981 817877 348712 862266 886243 144415 88253 168014 892670 747249 843649 59702 669725 387378 167413 174736 110224 1690 798816 849814 394048 657221 443290 440167 266745 843314 241217 980364 720024 517968 921625 340873 40442 410252 166346 905344 77…
Output: 641

Example 2:

Input: 616 99994286 307382 629888 491340 48028 494867 422256 917193 569772 183372 986621 650198 383588 881541 991772 998148 125701 608674 187446 405752 485285 491774 162505 904606 590402 525787 281740 550407 262238 984418 81954 651276 666858 754681 530783 330103 757466 233340 761947 889673 570319 271064 334061 666561 593290 697101 422603 195282 873076 307975 934966 259106 702902 99869 271125 181867 174892 768626 70602 620047 76375 886476 785956 205094 171790 286588 564098 217132 589509 175852 844883 264505 136191 179854 557061 279246 806944 955746 512376 459466 16652 800988 765921 843270 983098 566040 694969 859245 699123 184817 911705 886051 605464 983780 762908 78018 859456 758943 453317 429399 225800 62222 122354 550402 483929 108259 451150 306000 306528 431718 854872 215275 280526 996081 7058…
Output: 192

Example 3:

Input: 798 85573255 789411 961582 995248 380465 581 398460 838916 400448 542329 26245 704090 493483 98704 530378 231811 287813 378724 875552 989605 417721 314980 268682 939291 817999 879068 251615 280658 53461 616945 436967 836676 930710 905472 749792 472442 527690 591408 231429 764758 694487 201453 522619 601125 409084 299051 404055 913093 621849 349494 748111 712059 670536 265569 990915 591051 86986 138693 337566 918483 492175 313140 49864 499656 349094 921833 502582 126493 306743 772102 194818 348253 571611 636908 10733 576370 850508 895987 985970 473057 775769 124576 697881 216570 347548 546654 791349 748392 73848 124824 521163 443680 984577 139448 248049 695717 777646 626422 983970 320086 451859 552920 6708 329958 897473 342761 8240 550190 398073 228143 783884 848169 229963 984548 317122 628…
Output: 158

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Seth's Ledger of ribbons - MEDIUM Coding Problem | CodeTikki