Source Code
tmp = input().split(" ")
n = int(tmp[0])
k = int(tmp[1])
a = input().split(" ")
b = [0]*n
for i in range(0,n):
    b[i] = int(a[i])
ans = 0
while(True):
    for i in range(0, n):
        if(k >= int(a[i])):
            k -= int(a[i])
            a[i] = int(a[i])+int(b[i])
            
            ans += 1
        else:
            print(ans)
            exit()
    for i in range(n-1, 0,-1):
        if(k >= int(a[i])):
            k -= int(a[i])
            a[i] += int(b[i])
            ans += 1
        else:
            print(ans)
            exit()
Copy
Saqqa 26/40 SilverCryptor
Python 3
2068 ms
15.0 MB
Time Limit Exceeded