CT51209

Asha Counts the panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the foggy moor of Greyfen, Asha records each panels in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1731; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 765 361094926 186704 624524 70545 857362 211955 990579 639190 294543 91496 563363 139240 222070 904838 445137 257372 890529 506476 319729 491258 417128 17228 857199 286579 583954 675208 969318 245149 268622 634866 373482 426693 498146 252117 221208 337848 811874 884500 731712 995275 15196 896387 189493 484070 937611 470898 899527 545430 832347 575759 672628 420226 747751 661951 310142 773856 64342 965488 774877 208072 132127 339293 746271 525385 947879 411558 198956 426043 663118 891176 833957 32830 265671 720005 778712 510641 946699 208905 559647 899563 660957 33397 881512 4983 714346 281573 244279 562920 895905 245090 686627 583801 217612 637174 226078 373830 271943 958986 294425 729095 272688 769967 992326 323176 892860 171729 733437 272060 435954 180387 789339 796578 472151 520454 5814…
Output: 698

Example 2:

Input: 1125 446883671 822803 203313 30035 633810 505424 332471 625466 957621 825098 855808 13662 890262 154826 179797 3746 74313 211295 594672 387051 583840 40335 90013 118289 95558 319385 608599 731787 649844 483575 732759 906119 76397 537653 391685 682900 855538 782181 871506 122850 642915 13362 330645 120066 144421 627787 598884 766024 90465 330389 889100 415277 303122 122561 418538 901980 507481 332614 867963 891708 997729 770399 210842 878773 895934 331569 801692 490326 327829 991994 763593 312394 190150 661615 823554 651796 294390 323071 15486 962108 759252 994500 102412 736223 988303 809366 515523 650727 505106 718358 849183 290786 904620 240903 801149 557259 443627 749717 623545 833896 556061 739571 934408 287098 210902 936977 630871 876903 128357 804193 390164 921679 998191 943954 924822…
Output: 877

Example 3:

Input: 1656 83079223 334393 832907 576889 639437 717901 750592 234293 456954 665953 155510 148912 970259 79911 315887 488946 57256 227764 472691 383723 452684 544853 152265 565376 323639 287139 896727 765782 440654 722178 792513 310564 353027 72199 971007 512787 333970 474384 379914 938933 548206 309156 68355 115955 686695 969756 328818 940511 350760 680449 565187 27695 182391 977465 116257 902378 632729 842779 130086 39008 32756 23113 721205 580199 622092 674605 969100 231357 255926 271094 156634 132133 501038 159471 155270 97167 61492 570187 686826 870273 445336 635843 786972 956820 935378 565263 354512 472637 827146 384891 278200 957147 567738 781485 750941 572980 840708 76893 700973 452205 34236 200462 610405 111815 977984 834145 690604 483300 389587 191126 26445 566127 117129 324425 331542 5…
Output: 146

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Asha Counts the panels - MEDIUM Coding Problem | CodeTikki