题解 | #超市里扫货#

超市里扫货

https://ac.nowcoder.com/acm/problem/244927

这题我认为python选手最好要用deque来模拟,不断popleft直到deque空了就行了。

from sys import stdin
from collections import deque
input = stdin.readline
n,v = map(int,input().split())
l = deque(map(int,input().split()))
cnt = 0
while l:
    tempv = v
    while l:
        if l[0] <= tempv:
            tempv -= l.popleft()
        else:
            break
    cnt += 1
print(cnt)
全部评论

相关推荐

12-19 20:28
已编辑
门头沟学院 Java
美团履约 全栈工程师 (n+1)*15.5 其他
点赞 评论 收藏
分享
dian3b:挺妙的,如果上纲上线显得不合人心,但是这样以来既能监督适当摸鱼,也有一定的人文关怀。
摸鱼被leader发现了...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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