⌨️

[AtCoder]ABC-251|B - At Most 3 (Judge ver.)

2023/06/23に公開

設問ページ

提出結果

import itertools


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


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


def main():
    n, w = getIntMap()
    a = getIntList()

    b = []
    for i in range(3):
        for c in itertools.combinations(a, i + 1):
            d = sum(c)
            if d <= w:
                b.append(d)

    print(len(set(b)))


if __name__ == "__main__":
    main()

Discussion