题解 | #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]))
全部评论

相关推荐

爱吃烤肠的牛油最喜欢...:50K是ssp了估计,ssp的人家多厉害都不用说,每年比例大概在百分之5左右
点赞 评论 收藏
分享
09-01 10:50
已编辑
东华大学 C++
PDD校招_内推:拼多多意向和开奖一般都比较晚,可能10月11月才出意向
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务