CT44810

Manav and the Tightest Stretch

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the poppy fields of Scarlet Plain, Manav the archivist keeps careful count of the windows. rebuild the damaged itinerary, every figure matters. 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 <= 2763; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1480 536053368763 571379848 137390036 653080724 391761932 586194822 127357752 629934132 707227475 531560138 570046202 581526722 452658825 927377785 267820215 701675043 935597388 915490858 997971793 743422529 176484657 231549453 548460314 592952346 803542777 455010592 475189241 637615467 185615884 829441622 800502044 29556681 438705148 613589885 337316857 278964578 1252773 642405154 161694903 695900754 125747340 177355424 203390823 405652291 563442986 616460971 102899530 481039187 159339154 900776750 523036285 105149497 354100501 479431148 878709586 777947179 158945217 196723145 830180588 714444149 345166026 68720542 215331152 880179929 4601287 481433450 718231395 404095835 341253183 734628227 814053654 327804887 439726666 682257234 136006480 331200413 870903400 777155143 913908980 42148589…
Output: 1063

Example 2:

Input: 150 31424215049 176605769 831204656 907008926 484784862 820393349 250851579 239257726 978487837 315757551 67802082 312535229 421868639 412285672 762560609 907887755 736474992 280189436 761782276 291967302 912314761 7613621 181732112 306912550 771836065 26871134 801769853 14311901 799015187 210881839 347543842 316164415 675244363 2306263 644055059 866673992 568109774 681615092 81999447 345867048 828968451 113049632 427415960 181718897 624650543 653357737 7252347 553118922 742959034 234818895 695500222 693713134 738382090 712726469 985984465 859538617 997574822 263892817 357270387 933266705 866867204 494372126 317738154 237349862 269030064 541423602 687362570 400849769 787433131 909218618 331765326 180854013 998752228 398257804 131742535 384528572 902854627 308133381 383496612 600507090 4110…
Output: 61

Example 3:

Input: 256 32536521561 586920545 743264396 44067377 911147711 209142164 4145265 315332149 303350361 816331226 504098410 149109679 25624219 693609409 485894935 479706401 692614879 682026619 717928670 255523923 454598291 103392976 353590000 843671728 189711326 164481954 429998931 123327950 607529426 530042155 754352910 76106943 815691134 550951066 12633475 574068395 792392279 21285575 314393881 894715665 334035189 224596790 18236831 971468880 643479575 619442655 370781678 556780575 216001187 5636412 536316749 140500041 132559100 779043630 894659746 511857518 508436316 615182563 974228791 866208874 695662152 107589184 748617971 648637108 664157569 203177057 820701780 772610080 884758456 146809582 68915249 335098979 256740805 294829414 310980503 479845360 647282589 856108521 894531156 851881381 12986…
Output: 53

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Manav and the Tightest Stretch - MEDIUM Coding Problem | CodeTikki