Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file = open('1A.txt')
- N, M = map(int, file.readline().split())
- a =[int(x) for x in file]
- count = 0
- for i in range(N):
- sum = 0
- for j in range(i, N):
- sum += a[j]
- if sum <= M:
- count = max(count, j - i + 1)
- else:
- break
- print(count)
- file = open('1B.txt')
- N, M = map(int, file.readline().split())
- a = [int(x) for x in file]
- ans = 0
- l = 0
- s = 0
- for r in range(N):
- s += a[r]
- while s > M:
- s -= a[l]
- l += 1
- ans = max(ans, r - l + 1)
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement