CT56980

Urmila's Ledger of segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the galleon yard of Masthead pays by the answer, and Urmila intends to earn it. First: the full register of segments. 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 <= 1641; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1405 448782510 501329 809074 226531 113459 990556 861121 609471 277743 228869 660826 387456 987568 96532 110634 791221 697955 504886 420830 955534 54468 765732 990387 293488 579667 986902 332827 267396 412242 102022 604276 271870 641135 379924 641549 378320 463053 229921 682922 158033 315295 161555 10317 605768 867522 685340 325397 444215 790771 126285 220618 766649 465909 43926 675710 406398 905480 466659 751684 929313 225529 533945 356004 510319 125001 3267 190333 714488 84328 328088 270944 240533 158043 454853 95229 800463 587304 20152 232877 776839 383279 532060 409286 420508 113817 268246 144446 714957 223915 266058 520450 385061 112586 123512 419521 636670 794523 781018 8747 925274 185651 264766 17704 989133 954355 662787 920045 373975 423225 478187 444418 484523 327058 548898 642874…
Output: 882

Example 2:

Input: 943 416589383 481235 879984 261924 275843 674400 894862 407776 744177 326717 486008 243421 756230 977570 221880 392044 978989 236693 820904 337133 253080 33490 190520 830555 883829 927598 81997 842566 474857 984114 38674 407269 348339 566980 671976 410844 880017 703418 733768 552788 377713 128957 978842 219541 781625 409315 964484 222324 823626 214328 808289 516606 142057 302481 396748 437815 599132 11975 897689 430050 449759 896287 755510 733609 429162 362630 310218 978015 34043 412642 759139 905973 328525 210432 467119 149102 682677 788032 580762 369720 434420 292718 423204 994198 504453 335122 233786 583102 968530 903777 460682 793272 78899 515972 154622 813874 662879 539156 81019 24855 551268 447471 666311 109989 660398 992361 256958 248467 372729 570146 978862 765384 601408 54172 1701…
Output: 830

Example 3:

Input: 1263 364299069 695923 752988 294768 499802 599840 200754 408479 619609 173194 377348 192212 438072 222915 129004 280722 342947 259075 168520 368657 726092 863702 34295 70665 714714 744831 135331 597316 928494 818606 147443 743508 948492 344417 897997 281772 124948 484435 533900 475154 772379 193221 933609 446982 674263 141046 601232 117753 35340 101616 5096 843840 384756 238309 917125 787457 460048 656264 418263 141292 19861 195246 571955 476888 502795 815783 688631 760289 905252 141608 389316 203481 409171 672479 7292 86111 904822 7223 820004 177428 163857 203588 313262 368176 986478 542410 22176 327939 319018 468103 411394 836293 396643 884763 177839 344760 493698 244137 380818 859982 959957 958400 141868 292634 216593 178254 617333 623640 333600 176362 403824 255036 953948 862983 385625…
Output: 728

Constraints:

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

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