CT52244

Iris and the Polished windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Iris found an old ledger of windows in the granary attic at the foggy moor of Greyfen. The margin notes pose a precise question. 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 <= 1514; 1 <= a[i] <= 1000000000; 1 <= s <= 10^18.

Example 1:

Input: 1442 600653413773 579317327 272470067 550023772 300651058 745555325 77588514 489333840 164393388 233477102 74525397 571994315 589133311 144290771 229072356 788714858 351297156 13113732 797509572 242490155 359904595 403193551 86439415 765262388 185645660 468462052 639062325 254869632 724504266 169309683 47034032 686131598 255678662 418717236 384457435 645198618 209626005 620517254 660005386 460314764 978995979 79760106 252254270 876359084 974830621 551636950 298656147 710200551 543788068 660909387 212386954 883339492 320234975 395609281 337247556 866291266 342910405 640289690 89732321 344296766 609725289 544650099 980347231 758558953 907329609 195205722 378651028 271828888 155589262 141477925 46466511 390021850 774929407 164910565 413438415 872097019 814894918 216277945 594199227 842698421 …
Output: 1207

Example 2:

Input: 1099 540069782463 134964092 494840385 89314242 502694276 428446049 455590944 511509894 208080776 386694572 235295880 320880292 275405031 328630697 969048490 668762706 345125612 12114890 371465049 623880821 461837874 22452190 486638330 688003440 422319611 111884118 9764147 647416452 877645932 687645130 409133503 392260761 178673673 535616748 328048471 77527001 696576344 42218183 271756907 712889810 701130944 530205471 800461595 983275206 424631817 590175758 1556497 86839144 555541249 858508071 810258801 232352050 478523686 377878778 87620944 19033502 808275287 649683410 615872954 428887882 520029046 908867359 736756665 880938539 846711772 268646678 295235001 402545591 815442820 181136482 188862677 914313128 492445584 198355650 896870128 561688726 258210849 873150394 464942884 448365537 6775…
Output: 1090

Example 3:

Input: 402 13147143460 145998447 765054136 575667165 75433871 580171062 371883865 553666804 403608822 746643700 739309217 370261092 79836517 373098378 700580966 927639791 502810213 510462859 26792552 698083457 136524759 217316470 709072932 180685 289581333 478527923 41789025 854252585 155939858 640391388 404829643 11215533 808966839 321826373 221044282 623988327 892182168 173230051 523703997 416928274 482944457 266028876 155478625 905245138 369309041 66049899 130647042 192569263 833894847 431270064 336484296 228716165 946287811 683025838 389393246 199109250 354282651 264761019 794439956 635595734 522609056 446163559 840535918 37448417 740738151 349566691 82886777 238135827 237368089 79646421 216257881 713968090 314512334 914543128 636626225 654819337 727175684 721294416 254978618 205865062 207135…
Output: 21

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Iris and the Polished windows - MEDIUM Coding Problem | CodeTikki