有问题的HackerEarth上Python中的NZEC错误->“巧克力和盒子”

时间:2019-02-17 06:17:55

标签: python-3.x

我在HackerEarth上收到此“运行时错误-NZEC”,它可以成功编译,甚至可以在编译过程中对基本测试用例给出正确答案。我的代码在下图中->

# In the below line, I inputted number of test cases.
t=int(input()) 
# In below while loop, I am just repeating task for 't' times.
while t>0:
    t-=1
# In the below line, I am inputting a limit of numbers i.e 'n'.
    n=int(input())
# In the below line, I am inputting a list containing 'n' numbers 
# separated by space.
    numbers = [int(n) for n in input().split()]
# I am inputting a value in 'k'.
    k=int(input())
    count_ways=0
    csort_array=[0]*101
    for i in range(n):
        csort_array[numbers[i]]+=1
    a=k//2
    for i in range(1,a):
        count_ways+=csort_array[i]*csort_array[k-i]
    if k%2==0:
        count_ways+=(csort_array[a]*(csort_array[a]-1))//2
    print(count_ways)

请帮助! 预先感谢!

0 个答案:

没有答案