CT53750

Bram's Silent Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the fen lights of Will-o-Wisp with crates of windows, and Bram the surveyor must account for every last one. 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 <= 3105; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1261 90476153 486666 259685 906740 619549 668140 295974 233955 162089 489952 363817 280154 916916 98696 973690 81065 409904 542975 394265 862399 859499 44081 352906 193520 573091 225446 464879 636140 303358 507425 160016 164578 600126 967424 394358 120510 862820 21545 818473 504026 197341 603372 179009 341736 43361 86562 408188 279118 308362 926396 796218 855438 793279 21453 964632 492024 431237 382760 179886 517202 500792 269631 534930 534783 877581 509552 247232 304694 878388 718129 527786 931616 278166 478707 530018 6729 292655 932423 9367 459971 212439 793259 898696 734728 295994 971289 583504 530377 540225 693159 198623 836622 864549 334070 865131 827415 521388 895512 793453 245803 715936 475675 587137 905127 500507 323944 947312 553271 912984 270212 266487 46332 472222 991925 792610 …
Output: 161

Example 2:

Input: 2475 1101230761 575455 245015 441511 824473 737457 385050 86660 145863 971478 171522 874768 125414 50391 486286 206535 354704 645646 884165 758946 810592 37889 263184 987317 193522 72823 301355 66148 804533 201129 258322 538077 160514 596478 682513 67153 358474 176033 332567 197754 717709 777128 180523 529127 242797 792373 712307 916780 739863 385518 459344 155391 361981 724030 554900 232260 133916 618847 668868 774997 208212 968937 378270 236944 581826 114098 435558 718554 434381 483348 401728 225861 876607 456510 154236 222703 668408 170679 740178 601873 279618 656921 22272 342529 889015 613160 997012 699213 937886 831733 191771 662963 98725 314393 868110 230174 549835 7595 108558 970565 872000 997740 48848 572327 966751 121434 964910 310151 920612 862559 260047 710478 455146 146219 8236…
Output: 2211

Example 3:

Input: 1749 164692005 970578 902160 114786 60014 516912 304293 207962 479644 163952 874186 86325 41811 469392 835370 963496 549308 310733 409111 896282 583948 694815 129502 998704 442846 384947 148208 353550 186620 105207 811556 970775 148316 932646 355564 882865 306978 961440 172342 624237 872089 89566 949929 519328 154884 913131 769731 331625 10680 772217 860798 761002 20139 55738 958947 821352 606510 307089 749718 707975 336617 370689 719941 917660 866846 979308 524115 361840 399927 609552 106672 199984 506433 309947 69705 455947 540694 415443 976233 922346 248273 17813 631411 262273 852628 822950 716411 181988 120296 194880 788434 882444 437919 504314 796761 153988 189956 887094 482901 846840 105070 456771 416778 777913 387736 165605 793213 992076 985365 806966 746916 753833 289998 196000 560…
Output: 318

Constraints:

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

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