Answer to Question #346017 in Python for Cherry

Question #346017

Krishna owns n mobile phones (numbered 1 through n) he wishes to sell all of them in the coming next N years by selling exactly 1 mobile per year. The initial price of each mobile phone is pi . Due to depreciation , the price of each mobile phone decreaes by 2500 rupees per year untill sold.





Note that price of a mobile cannot drop below 1000 rupees no matter how many years have passed , ie when the price of a mobile reaches 1000 rupees in some years , it remains 1000 in all subsequent years .





Find max amount krihna can make by selling his mobile phones





Input




The first line contains a single integer t denoting the number of test cases




The first line of each test case contains a single integer n




The second line of the each test case contains n space seperated integers p1,p2,.....,pn





Output




For each test case , print a single line containing an integer

1
Expert's answer
2022-05-30T15:14:57-0400
print("Enter the number of test cases: ")
for i in range(int(input() )):
    print("Enter the number of phones Krishna owns: ")
    n = int(input() )
    print("Enter mobile prices [separated by spaces]: ")
    prices = [ int(x) for x in input().split() ]
    earned = 0
    while(len(prices)>0):
        earned+=max(prices) # finding the best deal
        prices.remove( max(prices) )
        for i in range(len(prices)):
            prices[i]-=2500
            if(prices[i]<1000): # min price is 1000
                prices[i]=1000
    print(earned)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS