結果
問題 |
No.1701 half price
|
ユーザー |
|
提出日時 | 2021-12-03 06:57:59 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 658 bytes |
コンパイル時間 | 109 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 20,352 KB |
最終ジャッジ日時 | 2024-07-05 10:49:52 |
合計ジャッジ時間 | 1,968 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 12 |
ソースコード
N,W = map(int,input().split()) a = list(map(int,input().split())) ans = 0 score = 0 cnd_list = [] cnd = [] flg = 0 def dfs(x): global score,ans,cnd,cnd_list,flg if score == W: cnd_list.append(tuple(cnd)) ans += 1 if x == N: return if score > W: return dfs(x+1) if flg == 0: flg = 1 score += a[x]//2 cnd.append((x,1)) dfs(x+1) cnd.remove((x,1)) score -= a[x]//2 flg = 0 score += a[x] cnd.append((x,0)) dfs(x+1) cnd.remove((x,0)) score -= a[x] return dfs(0) print(len(set(cnd_list)))