Account Balance

 Coding Problem Keys 

 Account Balance 

 Problem Statement 

The initial balance B in a bank account is passed as the input. The amount entered by the customer in N ATM withdrawal attempts is also passed as the input. The program must print the final amount remaining in the bank account. (Assume no other transaction will happen in the bank account in the mean time).

Note: Withdrawal amount is always a multiple of 100.

 Boundary Condition(s) 

100 <= B <= 10
1 <= N <= 100

 Input Format 

The first line contains B.
The second line contains N.
The third line contains N integers separated by a space.

 Output Format 

The first line contains the final amount remaining in the bank account after N ATM transactions.

 Example Input/Output 1 

 Input 

5000
4
2000 1500 2000 1000

 Output 

500

 Explanation 

After the initial two ATM withdrawals, the money left is 1500 and hence the third withdrawal cannot happen and is rejected.
The fourth withdrawal of 1000 is accepted and hence the final balance is 500.

 Example Input/Output 2 

 Input 

50000
4
10000 500 500 1000

 Output 

38000

 Note: Max Execution Time Limit: 500 millisecs 

 Solution 

 Programming Language: Python 3 Language 

b=int(input())
n=int(input())
l=list(map(int,input().split()))
for i in l:
    if b-i<0:
        break
    else:
        b-=i
print(b)

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Highly Profitable Months

Minimum Sum of Non-Negative Elements

Largest Possible Number With Digits

Top Scoring Batsman - TEST ODI 20-20

Print OddEven

Count Embedded Integers in String

String - Vowels Position Sum