⌨️

[AtCoder]ABC-130|B - Bounding

2023/02/16に公開

設問ページ

提出結果

def getIntMap():
    return map(int, input().split())


def getIntList():
    return list(map(int, input().split()))


def main():
    n, x = getIntMap()
    l = getIntList()

    if sum(l) <= x:
        print(len(l) + 1)
    else:
        p = 0
        b = 1

        for i in range(1, len(l)):
            p = p + l[i - 1]
            if p > x:
                break
            b += 1

        print(b)


if __name__ == "__main__":
    main()

Discussion