結果

問題 No.1701 half price
コンテスト
ユーザー Navier_Boltzmann
提出日時 2021-12-03 07:04:37
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 511 ms / 3,000 ms
+ 966µs
コード長 626 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 106,624 KB
最終ジャッジ日時 2026-10-15 02:48:37
合計ジャッジ時間 3,100 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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