Help me in solving ZCO14003 problem

My issue

Hey, I have been trying this for days, this problem in itself was easy, I solved and made the code but when I submit it, I am failing subtask 0 of task 1 and subtask 6 of task 2 for some reason, I do not know what is wrong with my code, I have tested several inputs and I


get correct answers.

My code


import array as arr
n = int(input())
arr.budget = []
for i in range(n):
    c = int(input())
    arr.budget.append(c)
arr.budget.sort()
m = 0
x = 0 
for i in range(n):
    rev = arr.budget[i]*n
    if rev>m:
        m = rev
    elif m>rev:
        x = m
    n = n-1
print(x)

Problem Link: CodeChef: Practical coding for everyone

@xenon54inert
just a few implementation mistake.
I have corrected it in your code.

# cook your dish here
import array as arr
n = int(input())
arr.budget = []
for i in range(n):
    c = int(input())
    arr.budget.append(c)
arr.budget.sort()
m = 0
for i in range(n):
    rev = (arr.budget[i]*(n-i))
    if rev>m:
        m = rev
print(m)

Thanks big brother

1 Like