CT42161

Theo's Gleaming Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the crane marshes of Stillwater, someone must assign crews to the morning shifts. This year the task falls to Theo, armed only with the windows register. 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 <= 1169; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 460 123403826739 155878644 375968761 174382309 477777256 21183761 471061825 410056103 382323720 756001277 683936883 769333818 20892873 668795209 457857228 495923919 861420281 338299866 442068976 240954362 286427958 793547581 982968947 123359138 785234855 194234572 578830546 683476920 896208264 360635398 742759972 312975063 892491688 643934309 250372876 841264177 527597795 871258900 70152688 350684581 978875547 830698041 227506543 253034830 104064935 756120126 221370864 97694523 971342697 689196803 701780419 749408009 795900841 747555943 112467067 678023085 946853202 878046492 110578287 512146570 666922796 640172695 855700849 552234510 832042238 239143366 5017112 682487526 507634361 253911554 438843926 859539112 71792773 215355933 623130574 24059939 314491309 255955305 295866242 986434493 3…
Output: 229

Example 2:

Input: 22 7829232712 674659495 549270686 336958375 588148017 320113534 656335161 983232070 829596 5542222 78801328 217356881 479984265 736437669 202196702 314623802 825096241 27176209 441443172 581623 350196557 551920499 624523060
Output: 21

Example 3:

Input: 601 27041362488 165494355 883463487 894430589 555306536 673736095 239723867 574684506 28297650 351811098 298806363 981706674 867040817 271589376 329829464 656596365 398440470 803639144 943359313 341541854 67162960 71582898 211105812 330109437 720010132 306028469 91728266 825521404 463333444 406760401 166345496 864862928 510366365 414671477 154166347 647339627 194089371 938070540 591254055 967172686 830551126 680922203 213582412 191138319 513226223 238645232 311678103 464562057 474871628 28035434 139116048 828684503 583929973 685658191 814888458 505056251 187916940 191748287 789590447 56350821 34239047 916520756 113417457 972370584 6200693 898182904 917710391 239867739 444660214 34677818 663034667 742649524 452574851 242955181 60139937 775680979 919108915 132099003 874905259 228413463 39395…
Output: 45

Constraints:

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

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