Medium Data Structures > Basic Data Structures

Our Lazy Arnab is happily married with his love of life “you know who” and they have a cute baby boy “why I am”. Class teacher of “Why I am” gives him a task to solve. As “Why I am” is also too Lazy as like his father Arnab so he asks your help to solve this problem. A sequence of N positive integers **(1 < N < 100 000)**, each of them less than or equal **10000**, and a positive integer **S (S < 100 000 000)** are given. “Why I am” need to find the minimal length of the subsequence of consecutive elements of the sequence, the sum of which is greater than or equal to S. If there is no such consecutive subsequence print **-1**. Input: ------ Input starts with an integer T (≤ 100), denoting the number of test cases. Each test case consists of two line of input . First line consists of two integers N and S. Then N numbers of the sequence are given in the second line of the test case, separated by spaces. Output: ------- For each case, print the case number and the minimum length of the subsequence of consecutive elements of the sequence, the sum of which is greater than or equal to S. Sample Input ------------ 2 10 15 5 1 3 5 10 7 4 9 2 8 5 11 1 2 4 3 5 Sample Output ------------- Case 1: 2 Case 2: 3

Shakil Ahmed

Language |
Time Limit (seconds) |

C | 0.75 |

C++ | 0.75 |

C++14 | 0.75 |

C# | 1.00 |

Go | 1.00 |

Java | 1.00 |

JavaScript | 1.00 |

Objective-C | 1.00 |

Perl | 1.00 |

PHP | 1.00 |

Python | 1.00 |

Python3 | 1.00 |

Ruby | 1.00 |

VB.Net | 1.00 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | Morass | Cpp14 | 0.01s |

02 | monir769 | Cpp14 | 0.02s |

03 | mir003 | Cpp | 0.03s |

04 | twyu0721 | Cpp | 0.03s |

05 | prateepm | Cpp14 | 0.03s |

06 | Sarwar05 | Cpp | 0.03s |

07 | Key_logger | Cpp14 | 0.03s |

08 | anik_JU | Cpp | 0.03s |

09 | feodorv | C | 0.03s |

10 | dip_BRUR | Cpp14 | 0.03s |

11 | tariqiitju | Cpp14 | 0.03s |

12 | sakib_muhit | Cpp14 | 0.03s |

13 | rayhan50001 | Cpp14 | 0.03s |

14 | seyedssz | Cpp14 | 0.03s |

15 | _dipu | Cpp14 | 0.04s |

16 | daihan_mbstu | Cpp14 | 0.04s |

17 | Sajal_Deb | Cpp | 0.04s |

18 | RafiulIslam_bd | Cpp | 0.05s |

19 | pulak_ict_mbstu | Cpp14 | 0.05s |

20 | Silent_Warrior | Cpp | 0.07s |

21 | bishal_biswas | Cpp | 0.08s |

22 | a_rahman | Cpp14 | 0.08s |

23 | smriad | Cpp14 | 0.09s |

24 | emrul | Cpp14 | 0.09s |

25 | ash12 | Cpp14 | 0.10s |

26 | haasib | Cpp14 | 0.10s |

27 | Rakib05 | C | 0.10s |

28 | RandyWaterhouse | Cpp | 0.10s |

29 | prantacse14 | Cpp14 | 0.10s |

30 | mehadi_sust | Cpp | 0.10s |

31 | Shajib | Cpp | 0.10s |

32 | devcoder | CSharp | 0.11s |

33 | SakibAlamin | Cpp14 | 0.11s |

34 | abdulmukit | Cpp | 0.11s |

35 | nurshuvo51 | Cpp | 0.12s |

36 | Robbinb1993 | Cpp | 0.12s |

37 | zyyxxx | Cpp14 | 0.12s |

38 | ikaadil | Cpp | 0.14s |

39 | nuhu_iu | Cpp14 | 0.19s |

40 | MaknunLakme | Cpp14 | 0.24s |

41 | ISMAIL_HOSSAIN | Cpp14 | 0.26s |

42 | MASUDUR_RAHMAN | Cpp14 | 0.27s |

43 | gamerrishad | Cpp14 | 0.28s |

44 | inzamamdu | Cpp14 | 0.28s |

45 | Zayed | Cpp14 | 0.30s |

46 | Ihtiaz | Cpp14 | 0.33s |

47 | moinul_shaon | Cpp14 | 0.33s |

48 | abinash | Cpp14 | 0.34s |

49 | Unseen | Cpp14 | 0.35s |

50 | dipta007 | Cpp14 | 0.36s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(