题解 | #Redraiment的走法#
Redraiment的走法
http://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa
经过测试,第一组用例末尾多了一个空格。需要把这个空格去掉才能用split(" ")方法。
#最大递增子序列
#多组输入处理
import sys
ipt=sys.stdin.read().strip()
ipt=ipt.split("\n")
for i in range(len(ipt)):
if ipt[i][-1]==" ":
ipt[i]=ipt[i][:-1]
ipt[i]=ipt[i].split(" ")
if (i%2)!=0:
for j in range(len(ipt[i])):
ipt[i][j]=int(ipt[i][j])
#ipt:[['6'], [2, 5, 1, 5, 4, 5], ['3'], [3, 2, 1]]
#186 13 322 264 328 110 120 73 20 35 240 97 150 221 284 324 46 219 239 284 128 251 298 319 304 36 144 236 163 122
def max_up_c(x):
dp=[1]
for i in range(len(x)):
if i==0:
pass
else:
cur=1
for j in range(len(dp)):
if x[i]>x[j]:
cur=max(dp[j]+1,cur)
dp.append(cur)
return max(dp)
for i in range(len(ipt)):
if i%2!=0:
print(max_up_c(ipt[i]))

