結果

問題 No.1701 half price
ユーザー ygd.ygd.
提出日時 2021-10-10 10:43:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 637 ms / 3,000 ms
コード長 794 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 77,956 KB
最終ジャッジ日時 2023-10-12 05:33:32
合計ジャッジ時間 5,969 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,332 KB
testcase_01 AC 92 ms
75,948 KB
testcase_02 AC 144 ms
76,536 KB
testcase_03 AC 85 ms
75,740 KB
testcase_04 AC 147 ms
76,620 KB
testcase_05 AC 90 ms
76,168 KB
testcase_06 AC 628 ms
76,796 KB
testcase_07 AC 637 ms
76,996 KB
testcase_08 AC 80 ms
71,460 KB
testcase_09 AC 87 ms
75,744 KB
testcase_10 AC 81 ms
71,340 KB
testcase_11 AC 85 ms
75,940 KB
testcase_12 AC 84 ms
75,888 KB
testcase_13 AC 84 ms
76,580 KB
testcase_14 AC 87 ms
76,364 KB
testcase_15 AC 84 ms
75,964 KB
testcase_16 AC 80 ms
71,480 KB
testcase_17 AC 442 ms
77,956 KB
testcase_18 AC 96 ms
76,432 KB
testcase_19 AC 102 ms
76,988 KB
testcase_20 AC 79 ms
71,240 KB
testcase_21 AC 621 ms
76,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline
import itertools

def main():
    N,W = map(int,input().split())
    A = list(map(int,input().split()))
    sgn = [0,1,2]
    ans = set([])
    Flag = True
    for L in itertools.product(sgn,repeat=N):
        if Flag: #最初は空集合
            Flag = False
            continue
        #print(L)
        temp = 0
        used = []
        for i,x in enumerate(L):
            if x == 1:
                temp += A[i]
                used.append(i)
            if x == 2:
                temp += A[i]//2
                used.append(i)
        if temp == W:
            used.sort()
            tused = tuple(used)
            ans.add(tused)
    #print(ans)
    print(len(ans))



if __name__ == '__main__':
    main()
0