鱼C论坛

 找回密码
 立即注册
查看: 7207|回复: 23

[技术交流] 鱼C论坛Python精英挑战赛(第四季02期)

[复制链接]
发表于 2018-11-19 15:31:32 | 显示全部楼层
def jishui(x):
    t=time.time()
    water=0
    for k in range(max(x)):
        y=[]
        for i in range(len(x)):
            if x[i]>=max(x)-k:
                y.append(i)
        if len(y)>=2:
            water=water+y[(len(y)-1)]-y[0]-len(y)+1
    t1=time.time()
    print(t1-t)
            
    return water
c=[11,20,62,6,15,87,27,50,98,52,55,16,48,38,80,80,85,80,7,58,52,4,68,99,29,42,2,1,61,88]
print(jishui(c))
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-11-19 15:32:31 | 显示全部楼层
def jishui(x):
    t=time.time()
    water=0
    for k in range(max(x)):
        y=[]
        for i in range(len(x)):
            if x[i]>=max(x)-k:
                y.append(i)
        if len(y)>=2:
            water=water+y[(len(y)-1)]-y[0]-len(y)+1
    t1=time.time()
    print(t1-t)
            
    return water
c=[11,20,62,6,15,87,27,50,98,52,55,16,48,38,80,80,85,80,7,58,52,4,68,99,29,42,2,1,61,88]
print(jishui(c))
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-11-19 15:33:16 | 显示全部楼层
怎么发有行数的代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-4-1 21:10

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表