Source Code
import math
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])
suma = 0
for i in range(0,n):
    suma += int(a[i])
    


ans = (-1 + math.sqrt(1 - 4*(-2*k/suma) ))//2

for i in range(0,n):
    a[i] = int(ans) * int(a[i])
print(a)

if(ans % 2 == 0):
    for i in range(n-1,0,-1):
            if(k >= int(a[i])):
                k -= int(a[i])
                ans +=1
    
else:
    for i in range(n-1,0,-1):
        if(k >= int(a[i])):
             k -= int(a[i])
             a[i] = str(int(b[i]) + int(a[i]))
             ans +=1
    


print(int(ans))

Copy
Saqqa 26/40 SilverCryptor
Python 3
20 ms
2.7 MB
Wrong Answer