結果

問題 No.1701 half price
ユーザー gr1msl3ygr1msl3y
提出日時 2021-10-08 22:31:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 77,160 KB
最終ジャッジ日時 2023-09-30 11:23:23
合計ジャッジ時間 3,431 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,936 KB
testcase_01 AC 76 ms
70,764 KB
testcase_02 AC 109 ms
76,944 KB
testcase_03 AC 75 ms
70,992 KB
testcase_04 WA -
testcase_05 AC 75 ms
71,156 KB
testcase_06 AC 111 ms
77,160 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 76 ms
71,148 KB
testcase_10 AC 73 ms
70,860 KB
testcase_11 AC 74 ms
70,768 KB
testcase_12 AC 75 ms
71,060 KB
testcase_13 AC 74 ms
70,960 KB
testcase_14 AC 74 ms
71,016 KB
testcase_15 AC 74 ms
71,004 KB
testcase_16 AC 75 ms
70,916 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 75 ms
70,916 KB
testcase_21 AC 111 ms
76,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, W = map(int, input().split())
A = list(map(int, input().split()))


def solve(n):
    S = []
    for i in range(N):
        if (n >> i) & 1:
            S.append(i)
    v = sum(A[s] for s in S)
    if v == W:
        return 1
    T = set()
    for s in S:
        if A[s] in T:
            continue
        T.add(A[s])
        ct = 0
        for t in S:
            if A[t] == A[s]:
                ct += 1
        for j in range(1, ct+1):
            if v-j*A[s]//2 == W:
                return 1
    else:
        return 0


ans = 0
S = set()
for i in range(2**N):
    ans += solve(i)
print(ans)
0