NZEC Error

Hi i am facing NZEC error. Not able to figure what is the issue as I have given the custom input and getting the correct answer.
This is my solution.
Problem link :CodeChef: Practical coding for everyone
/**
n=int(input())
for i in range(n):
p=int(input())
q=int(input())
a=list(map(int,input().split()))
count=0
for j in range(q):
if a[j]<p:
count=count+1

    prod=a[j]
    for k in range(j+1,q):
        prod=prod*a[k]
        if prod<p:
            count=count+1
        else:
            break
        
print(count)
        **/

Use ``` to format your code, I’m trying to run it but it shows Syntax Error.

1 Like

Hi I just modified the code
still same error …

t=int(input())
for i in range(t):
    x=int(input())
    n=int(input())
    l=list(map(int,input().split()))
    dp=[0]*n
    p=1
    if x>l[0]:
        dp[0]=1 
        p=l[0]
    else:
        dp[0]=0
    for i in range(1,n):
        if l[i]*p<x:
            dp[i]=1+dp[i-1]
            p*=l[i]
        elif x>l[i]:
            dp[i]=1
            p=l[i]
        else:
            p=1
            dp[i]=0
    print(sum(dp))
        
    

@aviral311 do u think this error is anyway related to map(int,input().split())

I don’t think it is related to

list(map(int,input().split()))

Though you may be accessing elements out of bounds.
You may refer here.
https://discuss.codechef.com/t/anitguy2-editorial/81757

2 Likes

For this problem there is no AC python solution…not sure if it related to elements out of bounds

Most probably it’s due to badly formatted test data.
A quite common occurence in External Unrated Contests :unamused:

1 Like