結果

問題 No.1701 half price
ユーザー Navier_Boltzmann
提出日時 2021-12-03 07:04:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 807 ms / 3,000 ms
コード長 626 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 99,584 KB
最終ジャッジ日時 2024-07-05 10:57:48
合計ジャッジ時間 2,969 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N,W = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
score = 0
cnd_list = []
cnd = []

def dfs(x):
    
    global score,ans,cnd,cnd_list
    
    if score == W:
        cnd_list.append(tuple(cnd))
        ans += 1
    
    if x == N:
        return
    
    if score > W:
        return
    
    

    dfs(x+1)
    
    
    score += a[x]//2
    cnd.append(x)
    dfs(x+1)
    cnd.remove(x)
    score -= a[x]//2

    
    score += a[x]
    cnd.append(x)
    dfs(x+1)
    cnd.remove(x)
    score -= a[x]
    
    return
dfs(0)
ans = set(cnd_list)
if tuple() in ans:
    ans.remove(tuple())
print(len(ans))
0