New + Python + SNUG_FIT

Hi, I am new here. And trying to solve SNUG_FIT problem. Running on my pc editor, program works , but here I receive this error.
Traceback (most recent call last):
File “./prog.py”, line 2, in
EOFError: EOF when reading a line

T=int(input())
S=[0 for y in range(T)]
for i in range(T):
    N=int(input())
    A=input().split()
    B=input().split()
    for j in range(len(A)):
        A[j]=int(A[j])
        B[j]=int(B[j])       
    summa=0   
    for j in range(N):
        L=min(A)
        O=min(B)
        maz=min(L,O)
        summa=summa+maz
        A.remove(L)
        B.remove(O)
    S[i]=summa
for i in range(len(S)):
    print(S[i])

Either use ``` above and below your code or link your submission.
This is your submission link.
https://www.codechef.com/viewsolution/29817360

@beatea can you refer my code - CodeChef: Practical coding for everyone
It is defficult to understand your code because of indentation.

1 Like

The number of operations required to find min is the size of the array and you are doing it n times so it will take n+(n-1)+(n-2) ... operation which for all test cases can add up to 2.5 \times 10^9. Instead, try sorting first, so the next element will always be the minimum. It is obvious that the order doesn’t matter.

2 Likes