CT45876

Xavi Counts the windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the cork grove of Barkhaven pays by the answer, and Xavi intends to earn it. First: the full register of windows. 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 <= 2569; 1 <= a[i] <= 1000000; 1 <= s <= 10^18.

Example 1:

Input: 1787 486491661 584014 306468 623215 631772 856405 679549 834510 56095 291104 784990 332059 767198 394635 450760 393907 522343 520369 904348 99592 967466 68774 223512 275410 425654 662131 484065 76648 717148 922199 610214 302174 708288 598433 983351 444360 865916 557044 418674 928866 214596 628871 688787 324705 663662 461905 938906 184104 881330 902409 65818 500295 957339 505849 433488 838425 656170 461932 943253 12246 298739 580680 141110 515675 151931 97606 587261 323928 656303 612726 915537 230275 160986 235906 232505 509694 282581 783846 189025 390778 891372 447675 734346 624205 423665 336836 545399 221096 542205 322896 491751 613687 139207 994899 44245 263514 63710 56092 697173 236879 533118 11378 867695 437996 488493 517210 390332 413744 174476 854975 529008 684217 126156 833949 88879…
Output: 941

Example 2:

Input: 333 138927877 774100 130 979195 462232 597741 743310 325499 954118 501644 813317 204836 856475 321484 178539 520244 173240 771794 788805 543778 526660 38079 381197 557566 160405 644022 277285 339234 252437 458407 900290 42501 719188 928881 703616 662089 373839 898033 910185 825452 975488 126864 985665 766907 761503 978203 521787 229677 879880 703237 633411 996474 724851 416828 838237 90656 178611 572613 614447 361170 128461 834649 872417 519845 604781 894238 13504 666008 820780 334507 474950 388527 998903 396096 89313 338224 188314 148358 156789 8269 265856 434874 91145 353515 687376 870340 282791 665631 720191 818603 277422 839914 168949 776539 473029 856213 713921 74302 969511 867691 82267 955991 135221 500237 112319 422576 240182 479052 963630 641919 825088 889453 352473 12133 707832 59…
Output: 269

Example 3:

Input: 675 269288719 716224 792115 749775 697141 745629 935348 19591 111066 370840 484213 877141 121785 122327 403273 522116 552711 638927 2186 568367 803234 668045 236010 715629 105353 918078 826282 948013 875395 712451 82210 678180 927828 717431 250056 458911 734836 366468 678637 18914 352496 570859 979327 650106 393139 707360 962274 758000 339853 294710 377916 230638 219128 490859 107399 705199 822563 210466 1663 182735 43581 193035 213151 345662 90000 842521 27731 995344 963409 722443 46660 457906 714462 147224 918858 493524 113029 138326 404007 961860 78643 709917 603446 444946 628838 849085 155956 949428 413004 807224 449099 277680 75895 702384 84630 172253 125585 134703 893157 809271 763756 335346 322728 957321 449290 387093 550302 613625 472610 896064 32299 832204 84353 329212 180082 2950…
Output: 500

Constraints:

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

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