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 | seyedssz | Cpp14 | 0.03s |

05 | Key_logger | Cpp14 | 0.03s |

06 | dip_BRUR | Cpp14 | 0.03s |

07 | Sarwar05 | Cpp | 0.03s |

08 | feodorv | C | 0.03s |

09 | anik_JU | Cpp | 0.03s |

10 | sakib_muhit | Cpp14 | 0.03s |

11 | rayhan50001 | Cpp14 | 0.03s |

12 | twyu0721 | Cpp | 0.03s |

13 | prateepm | Cpp14 | 0.03s |

14 | tariqiitju | Cpp14 | 0.03s |

15 | _dipu | Cpp14 | 0.04s |

16 | Sajal_Deb | Cpp | 0.04s |

17 | daihan_mbstu | Cpp14 | 0.04s |

18 | pulak_ict_mbstu | Cpp14 | 0.05s |

19 | Silent_Warrior | Cpp | 0.07s |

20 | bishal_biswas | Cpp | 0.08s |

21 | a_rahman | Cpp14 | 0.08s |

22 | smriad | Cpp14 | 0.09s |

23 | emrul | Cpp14 | 0.09s |

24 | mehadi_sust | Cpp | 0.10s |

25 | haasib | Cpp14 | 0.10s |

26 | ash12 | Cpp14 | 0.10s |

27 | RandyWaterhouse | Cpp | 0.10s |

28 | Rakib05 | C | 0.10s |

29 | prantacse14 | Cpp14 | 0.10s |

30 | SakibAlamin | Cpp14 | 0.11s |

31 | abdulmukit | Cpp | 0.11s |

32 | devcoder | CSharp | 0.11s |

33 | Robbinb1993 | Cpp | 0.12s |

34 | nurshuvo51 | Cpp | 0.12s |

35 | zyyxxx | Cpp14 | 0.12s |

36 | ikaadil | Cpp | 0.14s |

37 | nuhu_iu | Cpp14 | 0.19s |

38 | MaknunLakme | Cpp14 | 0.24s |

39 | ISMAIL_HOSSAIN | Cpp14 | 0.26s |

40 | MASUDUR_RAHMAN | Cpp14 | 0.27s |

41 | inzamamdu | Cpp14 | 0.28s |

42 | gamerrishad | Cpp14 | 0.28s |

43 | Zayed | Cpp14 | 0.30s |

44 | Ihtiaz | Cpp14 | 0.33s |

45 | moinul_shaon | Cpp14 | 0.33s |

46 | abinash | Cpp14 | 0.34s |

47 | Unseen | Cpp14 | 0.35s |

48 | dipta007 | Cpp14 | 0.36s |

49 | mamun4122 | Cpp14 | 0.37s |

50 | ahmeddinar | Cpp14 | 0.37s |

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. :(