G M01 - Condiments in a Bowl HAckerrank Python

 Input Format

image

Constraints

image

Output Format

Print the total number of new candies Bob adds to the bowl during the party.

Sample Input 0

8 4
3 1 7 5

Sample Output 0

11

Explanation 0

image

SOurce Code:

# Enter your code here. Read input from STDIN. Print output to STDOUT

n,t=[int(i) for i in input().split()]

a=list(map(int,input().split()))


x=n

count=0

for i in range(t-1):

    x=x-a[i]

    if x<5:

        count=count+(n-x)

        x=n

print(count)

Comments