CT47874

Last panels of Owen

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the mushroom groves of Fungaldeep with crates of panels, and Owen the tallyman must account for every last one. 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 <= 3273; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1160 316833725 723191 426221 609940 246223 596882 914239 478861 404533 146973 238655 617453 23479 537629 150444 133867 904651 691195 271120 428531 123864 33961 161926 439763 967229 743123 972287 506881 354003 590074 271270 448697 988329 408204 41096 595860 606129 367575 214763 801731 362995 436370 177290 259902 488403 880631 574757 818800 508518 160563 5904 561424 674421 604115 387147 951886 167059 275118 316111 435016 972219 449983 640794 802166 290519 501096 932803 934107 129796 51061 599933 289310 603123 765435 673079 625186 586216 693113 168932 863536 67096 212223 345577 526826 487941 478759 505704 802443 326140 250188 36438 57128 434905 79933 552282 995247 991816 582574 961199 184726 279092 779323 884821 842729 223705 205095 377665 672883 2937 190633 809665 184013 152382 172195 905208…
Output: 616

Example 2:

Input: 1972 971668469 57004 492276 907309 129630 197847 2912 652014 113777 856021 904845 9673 254113 991295 232161 375454 369511 241027 836406 783959 689164 972389 770275 269419 490710 515070 359740 519463 431040 377796 114199 638126 889612 210518 963044 325514 669638 114695 239634 554842 406333 928125 964714 692201 335084 81119 600968 71021 221251 420329 741113 357717 252009 52769 868549 431398 106584 281457 660924 998658 628500 998161 321840 399966 141634 980520 765853 848906 628801 53859 401810 90134 800868 978062 296579 698837 652403 383392 743451 806261 908571 421410 710367 81400 954106 317766 535807 151163 872999 330358 234688 794530 613349 934248 61723 99682 330622 885341 504087 145834 296828 942672 781192 127328 458652 994953 436458 992580 488718 13201 381971 165777 993278 196500 884128 9…
Output: 1972

Example 3:

Input: 136 68287452 462083 767648 274654 813840 326882 873089 735740 632300 621171 618096 108864 628951 484391 864961 171476 538026 805148 460209 77473 336753 397129 583200 628944 602480 281492 15323 909094 501894 322552 80106 682634 48470 162799 649004 624282 827496 432308 435098 963523 891782 661890 609981 371115 754743 21602 785611 5351 213661 923940 853821 128094 514621 280808 510187 243700 798288 605161 564220 49333 682221 71614 641644 449089 904072 958804 30571 246478 24883 909353 921942 926419 582090 624063 229090 279948 873635 123702 633115 818341 449795 195592 376494 764037 925356 997871 640997 993749 77697 138084 658308 297234 745055 282120 205266 473004 482069 552166 411549 510027 738677 767843 122850 510392 803847 763304 654665 899114 256708 324624 485425 341774 189449 23056 650569 51…
Output: 136

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last panels of Owen - MEDIUM Coding Problem | CodeTikki