1 / 9
Jan 2012

i am asking how to read test case from file of spoj..i know how to read input..but asking far reading input from spoj test case file not from my keaboard....

i tried to solve spoj.pl/problems/HOTELS/26 in python i have already submitted it in C++..but it is not code in python shows error...in this probelm we need to read test case from file of problem...but i have taken n(number of input ) from user..my qestion is how to read teat case of file given in problem...

n=int(input())
v=int(input())
s=0;
l=[]

while(s<=n-1):
integerinput=int(input())
l.append(integerinput)
s+=1

maxhere=maxsofar=i=j=k=0
while(i<=n-1):
if(maxhere+l[i] maxhere=max(0,maxhere+l[i])
i+=1
elif(maxhere+l[i]==v):
maxsofar=maxhere+l[i]
break
else:
maxsofar=max(maxhere,maxsofar)
maxhere=maxhere-l[k]
k+=1
print (maxsofar)

No. Read my former post. According to problem description the Input consists of two lines. Read them and process them.

By the way: I don't think it will be possible to solve that problem with Python 3.1 because of too much input and to strict time limit.

@numerix
ok then help me m getting NZEC in problem while i have submitted same in C++ my python code for problem is

n=int(input())
v=int(input())
s=0;
l=[]

while(s<=n-1):
integerinput=int(input())
l.append(integerinput)
s+=1

maxhere=maxsofar=i=j=k=0
while(i<=n-1):
if(maxhere+l[i] maxhere=max(0,maxhere+l[i])
i+=1
elif(maxhere+l[i]==v):
maxsofar=maxhere+l[i]
break
else:
maxsofar=max(maxhere,maxsofar)
maxhere=maxhere-l[k]
k+=1
print (maxsofar)

please check out..and match it output as given problem it will work in all case please help me..and tell me how to submit it ..looking forward for your helping hand..i am newbie in python and justed shifted from C++ to python