Find largest sum of subsequence
Python, 91 84 64 chars
s=m=0
try:
while 1:s=max(s+input(),0);m=max(m,s)
except:print m
Takes about 14 12 72 seconds on the last test case. Edit: using algorithm Paul R found. Edit: nixed the import, using input()
.
C, 100 characters
main(){char s[80];int i,m=0,n=0;while(gets(s)){i=atoi(s);n=n+i>0?n+i:0;m=m>n?m:n;}printf("%d\n",m);}
Run time = 1.14 s for final test case (10000000) on 2.67 GHz Core i7 with ICC 11.1 (previously: 1.44 s with gcc 4.2.1).
Note: The algorithm used for the above solution comes from Programming Pearls by Jon Bentley. Apparently this algorithm is known as Kadane's Algorithm.
Ruby, 53 characters
p$<.inject(-1.0/s=0){|a,b|[s=[0,s+b.to_i].max,a].max}
Takes about 28 seconds for the last testcase here.