結果

問題 No.1701 half price
ユーザー playerplayer
提出日時 2024-01-16 02:51:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,014 ms / 3,000 ms
コード長 484 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 339,420 KB
最終ジャッジ日時 2024-01-16 02:52:08
合計ジャッジ時間 9,023 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 43 ms
60,224 KB
testcase_02 AC 234 ms
102,992 KB
testcase_03 AC 48 ms
60,224 KB
testcase_04 AC 233 ms
102,984 KB
testcase_05 AC 70 ms
70,948 KB
testcase_06 AC 2,014 ms
339,420 KB
testcase_07 AC 2,001 ms
339,420 KB
testcase_08 AC 36 ms
53,460 KB
testcase_09 AC 43 ms
60,224 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 43 ms
60,224 KB
testcase_12 AC 44 ms
60,224 KB
testcase_13 AC 43 ms
60,224 KB
testcase_14 AC 44 ms
60,224 KB
testcase_15 AC 46 ms
60,224 KB
testcase_16 AC 39 ms
53,460 KB
testcase_17 AC 650 ms
156,600 KB
testcase_18 AC 63 ms
70,948 KB
testcase_19 AC 73 ms
76,712 KB
testcase_20 AC 37 ms
53,460 KB
testcase_21 AC 1,896 ms
339,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *

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

sequences = list(product([0, 0.5, 1], repeat=n))
used = set()
for seq in sequences:
    seq = list(seq)
    lis = []
    cost = 0
    for i in range(n):
        if seq[i] != 0:
            lis.append(i)
        cost += int(seq[i] * a[i])
    tup = tuple(lis)
    if tup in used:
        continue
    if cost == w and len(lis) > 0:
        ans += 1
        used.add(tup)

print(ans)
0