CT43518

Manav Counts the windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the trading post of Goldmeadow close for winter, Manav must finish the windows ledger - one figure at a time. 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 <= 1009; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 606 223825439881 898604696 11349461 409566893 242433183 155372451 613237355 349590296 45922235 586866669 456109753 492176577 428158022 866601468 8301039 806669674 278170245 68282658 663450914 21420761 489722687 939163390 633868337 914412746 954433980 553205559 768797314 14683937 461452513 650326157 336830479 382876199 154353506 964774629 946830758 397075875 384041131 852301151 806077507 102750067 99079268 210570034 78119145 345893030 601635329 482984119 941103117 416610351 110847956 469319167 155574860 573033051 110972710 691170503 884471502 885442946 688508271 989232358 653507273 24891116 431200314 55533310 760532733 750342160 454694642 715802921 345205559 531476967 631658715 498646130 739606111 330053031 228961585 858088483 334106383 689121093 820893581 610050466 527362659 89379199 93551…
Output: 437

Example 2:

Input: 658 1245870596 313177072 962101772 330346645 437043159 793736536 394473497 752898849 997574732 742538799 929115654 277557978 904703222 745783473 125801214 154664611 938238751 817857079 732127946 944305558 103111735 456817317 996674669 192436928 783527231 221739509 752303815 779775936 342250356 114062877 554420500 471735696 999853187 562388402 106377829 823280188 414693696 45844781 451235557 511076936 688594622 56065761 408095417 204020159 605861214 239060291 13179129 414185180 52146990 278123167 753994812 445953439 996662563 909658593 850857750 640432902 860788420 809801850 246740147 365660630 417207918 982823014 279594142 360741240 567097264 83444774 159719642 579335151 255277023 293565068 776961578 67870256 606502104 76294251 459732949 648071235 673910437 673508144 975736264 542918199 72…
Output: 2

Example 3:

Input: 560 196453874392 331003098 888534978 994117178 205376489 318636954 979582707 808213445 213993859 832390276 106966810 958925798 19463188 327171051 123696847 176727407 973973481 938871620 317104790 34984973 725495769 486437338 306866389 500188546 429816493 243409786 884362986 679952130 364838320 562916236 938573568 793643148 210412703 533686058 153016152 546352748 439438724 828819646 605422400 925945616 446518353 747175327 26203338 473442355 472486106 95894981 499245885 539463502 789478322 371134411 544977020 968394465 370773280 136992259 950371564 444575015 26093072 17619787 66795125 829019315 554299575 669980120 426160939 947778507 863044217 637051338 707898356 991854715 535812250 61045559 20200083 946341365 944876702 794728467 400504363 808478383 261692601 494904639 336493347 391196869 72…
Output: 394

Constraints:

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

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