CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #953 #955 →

#954. Longest part with sum at most S

You get a list of positive numbers and S. Find the length of the longest part of neighboring elements whose sum is not greater than S (two pointers). ### Input The first line has n, the second line has n integers separated by spaces. The third line has S. ### Output A number.

Examples

Input
4
5 10 8 3
6
Output
1
Input
15
1 10 10 10 8 2 7 5 2 5 2 8 2 2 1
29
Output
8

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!