0
import psyco
psyco.full()
n=int(raw_input('Enter how many test cases'))
out=[]
for i in range(n):
    r=raw_input('Enter the number of people and minimum distance')  
    temppeople=''   
    tempdistance=''
    l=len(r)
    k=0
    z=0
    newpos=[]
    dis=[]
    while r[k]!=' ': k=k+1
    for j in range(k): temppeople=temppeople+r[j]
    for z in range(k+1,l): tempdistance=tempdistance+r[z]
    people=int(temppeople)
    distance=float(tempdistance)
    print 'Enter the respective distances'
    pos=[float(input()) for m in range(people)]
    if (pos[0]+pos[1])<=distance:
        newpos.append(0)
        newpos.append(distance)
        z=distance
    else:
        newpos.append(pos[0]/2)
        newpos.append((pos[0]/2)+distance)
        z=(pos[0]/2)+distance
    if people>2:
        for a in range(2,people):
            z=z+distance
            newpos.append(z)
    for b in range(people):
        dis.append((abs(pos[b]-newpos[b])))
    out.append((max(dis)))
for q in out:
    print q

我为code chef 中的 flushot 阵容问题编写了这段代码。但是它显示运行时错误。我认为这是由于数组大小。我该怎么做才能更正代码。

4

0 回答 0