CT44506

Nila's Crystal Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Nila the paymaster watches over the northern keep of Frostgate's stores of ribbons. A careful computation stands between order and chaos. 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 <= 1846; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 316 52799391 333748 449611 444305 580405 346996 740286 212755 753433 959100 279308 465050 613827 847147 670224 371181 629042 24173 637526 297101 153454 841245 116034 118271 414404 985316 922930 956239 782256 159969 303779 901956 600958 899324 209936 240404 40197 562155 650733 830511 262405 612148 888071 891876 775535 169040 311556 176413 21370 261693 244384 397417 160255 892366 515530 869678 956478 127864 754111 709065 139063 980148 518672 592689 795592 322573 219728 546662 706072 767000 908372 424331 72588 175598 806055 183227 185209 526560 443271 548423 130532 216916 456661 84642 849212 148574 824351 709554 273831 731000 118055 594761 120770 281581 640511 948156 601701 303063 80453 619109 361014 448885 506649 765235 603923 147084 999071 651269 632206 261019 416825 911752 763300 967333 44…
Output: 103

Example 2:

Input: 463 230061967 540995 675668 585864 933554 741593 524042 932047 995433 740321 780970 372804 31934 403618 758754 383217 63617 483818 139542 807163 443779 917709 991853 81542 921011 806453 950458 270669 188530 499835 247000 654195 550495 970709 586437 488098 157130 560320 683517 595824 323340 922146 465609 51498 270583 877304 541444 602208 997943 532236 945845 612267 94232 928198 252636 537242 435555 573477 927244 515721 846957 629542 718322 945512 522525 185348 196751 38701 722743 601110 583475 588621 717311 383269 7569 245324 47213 92199 264801 975489 404519 737243 984126 167001 779440 785646 715785 171871 90102 825371 592652 471687 241675 776509 757469 420083 889412 471048 717556 733297 296520 88637 154985 764417 445899 105574 180822 673988 568035 209758 288265 953064 236000 572202 574178 …
Output: 431

Example 3:

Input: 618 78725392 670165 965631 158341 928225 569714 887900 821667 507448 178745 753222 169791 832876 109577 693705 570426 592543 826899 996603 819017 332967 319427 450769 487187 12334 893976 246582 203314 244406 27114 446755 932265 42122 170255 265224 580244 346156 305446 719216 626471 476777 746332 605558 635276 463482 11530 194122 849129 459558 187626 93563 457170 641785 918631 513585 442582 170860 692380 963732 629898 892416 422670 399966 233209 363933 821529 426162 366119 456009 240978 368867 280252 840854 827823 607030 57454 291186 977819 604731 420661 50059 773057 646577 843563 438088 878055 608457 571069 831726 438563 659652 293171 616064 276589 97371 706136 958798 12851 28654 732510 6382 455967 87023 921462 200237 770802 173311 955257 363003 486263 500676 190803 823047 570914 148871 18…
Output: 145

Constraints:

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

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