Smart Phone

coz they will be paying 30 and not 30 or 54
you need to get price that all the customers will pay
revenue = price * customers that buy them
customers only buy them if price is lower or equal to their expectations

i have done this according to your explanation but still its showing partially correct.

code given below

num = int(input())
budget = []
while num>0:
b = int(input())
budget.append(b)
num-=1

revenue = [];
for price in budget:
r=0
for i in budget:
if i>=price:
r += price
revenue.appendÂŽ

revenue.sort()

print(revenue[-1])

n = int(input())

inp = []

for i in range(n):

inp.append(int(input()))

inp.sort()

def smart(n , inp):

minm = []

for j in range(n):

    if minm == None:
        minm = inp[j]*(n-j)
    else:
        minm.append(inp[j]*(n-j))
return max(minm)

print(smart(n, inp))

Thank You sir for sharing explaination for this problem. It’s very helpful

Hello Everyone, I have implemented solution for Smart Phone Problem and this solution gives correct output also but after submitting this solution my submission


status showing wrong . Anyone can help me what changes required for successful submission. Below I have mentioned my solution

Please either paste your (formatted!) code or (better!) link to your submission - no one wants to squint at a PNG :slight_smile:

Solution: 53048725 | CodeChef

1 Like

Thanks! That’s not “wrong” (WA), that’s “Time Limit Exceeded” (TLE) i.e. your solution is too slow.

Thank you sir, so i need to change whole solution or can i run this solution with any changes?

Can we do this problem without sorting like using DP? In O(n)?