题解 | 牛牛与切割机

牛牛与切割机

https://www.nowcoder.com/practice/cda06078a54142d29da7adc3b9ad5880

n = int(input())
a = list(map(int, input().split()))

sum_total = sum(a)#列表中数字总和
sum_left = 0#左边列表数字和
min_mul = float("inf")#最小切割代价
for i in range(n - 1):#遍历列表寻找最小切割代价
    sum_left += a[i]
    min_mul = min(min_mul, sum_left * (sum_total - sum_left))

print(min_mul)

全部评论

相关推荐

02-11 14:29
已编辑
字节跳动_QA
Edgestr:这种的写代码最狠了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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