CT55854

Last windows of Shepherd

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Shepherd the valuer watches over the crystal caves of Luminar's stores of windows. 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 <= 3669; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 2058 15502340346 831978928 257002585 584420063 983422420 537480852 718476365 413832484 400105546 837884606 344701967 489186261 581660824 524762493 399367371 210474783 603591871 58945245 515579657 377539153 579990950 493398133 416059245 787200241 8617040 808738011 308555769 320579711 294454444 957868471 186397533 457284911 821750544 255014972 435376189 24807227 512090680 241116222 162077485 787471879 539082782 655280047 379364772 241712957 661101424 255806403 495000315 925755155 981369468 489224453 176019872 652765051 447025852 159347605 458375949 950188168 39588104 813231669 698367983 472948625 426146032 391787015 552032850 750273301 547863066 78209383 662661922 812210972 635714394 489940054 683878939 493743268 796966798 538111443 478675901 682484974 376287721 379472514 161012304 278137369…
Output: 25

Example 2:

Input: 2593 140606664549 129311836 284360100 698046792 278793455 22821229 644319997 704057418 878748444 875347373 419390385 622228127 209834452 615615720 70294177 675865908 915225946 65282186 576909424 800887243 744344981 426917055 218238027 585763552 997261554 252433781 443614108 484260501 282587875 916790428 23088805 667523254 763887981 501563427 441229174 578649465 305119077 170366688 45530603 358379594 200849973 650209851 910197240 846223642 466806436 426971024 812783632 517314408 712238098 86814903 161052209 953448441 590332002 83056204 318974870 107276996 743656791 687649086 511799316 946975378 92618852 547722456 378438050 839959697 830702163 590364368 759352397 27370825 279694010 901930625 487589564 105896383 209253664 649858886 267047297 477192449 408131735 10351352 556268640 601741598 63…
Output: 259

Example 3:

Input: 3305 1564005596567 99926625 85253368 253954642 875554078 427975569 440792647 215864238 640360834 370192699 662612931 205887234 512459439 879527713 332860460 333646803 261362802 266373819 360572503 198996623 947704015 676882977 495661660 13683543 663500384 989390183 274154427 836549929 875705537 177824694 757144215 914059512 544554222 697773652 875038398 275624501 261807894 25765587 263913314 967406277 429434325 290748773 109840418 977523144 699296904 623819025 629976699 470895052 611491595 119730153 667930722 440472142 799479925 98627697 429539152 799468140 177390934 713982412 801754358 796028049 247744248 297722694 331922482 766594011 534170652 944925669 40368202 903966476 232875669 766140216 953964372 382465854 276389440 626393781 563140115 708472551 293276194 513781657 854886877 4803831…
Output: 3059

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last windows of Shepherd - MEDIUM Coding Problem | CodeTikki