In a new banking system, interest is calculated in the following manner. Let A be the total amount in the account of account-holder of the bank. And p be no of times an account-holder has deposited cash , and q be no of times he withdrew cash from the time of creation of his account till date. Then, interest =(Amount left in account)*[ min((2^p / 3^q), 0.1)]; Interest is calculated every 12 months.
Given details of timeline of events for an account. The given details is in ascending order of no of months elapsed since creation of account. Calculate amount left in the account at end of last transaction term.
A: amount with which bank account was opened N: No of transcations made X: No of Months passed after creation of account Y: Transaction Amount
If Y is positive, amount was deposited, if Y is negative, amount was withdrawn
Total Amount in account is always non-negative value.
Input : First line contains A, N Next N line follows which shows transactions in following manner. X Y
Output A single integer , i.e. Integer value of Amount
Constraints : 1<=A<=10^8 1<=N<=10^4 1<=X<=10^8 1<=|Y|<=10^7
After first 12 months, amount left in account is 100+50+50+100 =300.
No of deposits (p)=3;
No of withdrawls (q)=0;
So, interest after first 12 months=300*(min((2^3/3^0),0.1)) = 300*min(8,0.1)= 300*0.1= 30
Amount after first 12 months =300 +30= 330
After next 12 months, amount left in account =330+100-200 =230
p=4
q=1
Interest= 230*(max((2^4/3^1),0.1)) =230*max(5.33,0.1)=230*0.1=23
Total Amount at the end of 24 months= 230+23=253