CT56702

Sahil and the Woven panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sahil found an old ledger of panels in the mint attic at the peat bogs of Mossgrieve. The margin notes pose a precise question. 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 <= 3931; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 2246 46879070989 624480000 378142845 210680471 401792541 133032463 421746891 217880064 458036657 400280503 915031573 137970089 546116949 421963118 682618386 261209043 628272993 282133374 544226268 8834384 274710929 386588128 650672286 719665978 213732849 42968636 230424049 179496235 656136858 400569883 260872048 730319508 286717537 173527005 762549636 291146243 291341095 825390218 222113332 774950122 302561037 777801040 897473430 845999937 736495210 682893015 802032886 857909262 296392155 130677489 635347007 521578645 260353987 455998771 497011546 320505932 168863732 82567488 512520068 909770747 965852077 10967022 1661062 356335195 352325819 120962773 892625573 348332860 137996662 797877557 731065474 559348824 2864745 23829326 889776948 221557907 836778970 613435342 632022763 405759840 489…
Output: 80

Example 2:

Input: 2485 249542450137 398097117 76899154 31228292 777535373 963228503 463693053 604218443 72868434 630678967 609218936 453046309 453876685 887915333 744768222 718527658 424998975 213653129 339145042 761571260 518399266 632177659 676708399 844687095 334590227 844639455 55914396 678398817 676203562 72705208 940058796 662163309 4583149 510380644 450133394 868016549 782111234 642013688 140128905 125575275 911234035 536435131 93170404 833320127 74961356 564708769 109696739 872156008 946838534 767561124 414596511 247359106 652892095 50431933 669445662 117250799 526447606 754609115 67385724 140666042 523500522 529117258 792070435 690465738 360125819 755526328 503427294 795230402 634694979 415718254 214049668 859711687 521320158 758507976 79174095 112536987 233261267 869880634 225386959 757975662 3021…
Output: 468

Example 3:

Input: 1358 228750628848 941022318 614089685 630061229 873909242 569671885 510208568 659933523 636679129 165556948 583449429 625173747 111601455 234137638 877978288 446450279 900627027 966175599 597795064 137249632 645133879 606894655 426791405 375852114 758697167 130265014 16802155 348291955 497864449 616259390 361322766 179720494 5352448 4226381 98902465 838994054 285912579 737474216 588381972 67672495 449009456 357222163 326570653 677196085 131942503 427549010 674294840 436829943 381247153 941358766 432404583 856944336 479372416 9999678 617462055 646173477 647587261 862334241 562548592 735843765 164329320 377837728 425790896 630967801 299470702 593133357 562969259 76240195 969301057 26316641 507695553 566871357 846384083 18955636 741312022 812680584 754060368 201703727 468802326 542466708 6186…
Output: 454

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.