結果
問題 |
No.1701 half price
|
ユーザー |
![]() |
提出日時 | 2021-10-08 22:13:07 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 753 bytes |
コンパイル時間 | 1,828 ms |
コンパイル使用メモリ | 213,712 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 12:44:22 |
合計ジャッジ時間 | 2,585 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 WA * 4 |
ソースコード
import std; void main() { long N, W; readf("%d %d\n", N, W); auto a = readln.chomp.split.to!(long[]); void dfs(long num, long cnt, long bit, ref bool flag) { if (cnt == N) { if (num == W) { flag = true; } } else { if (bit & 1) { dfs(num+a[cnt], cnt+1, bit>>1, flag); dfs(num+a[cnt]/2, cnt+1, bit>>1, flag); } else { dfs(num, cnt+1, bit>>1, flag); } } } long res; foreach (i; 0 .. 1<<N) { long b = i; bool canChoose; dfs(0, 0, b, canChoose); if (canChoose) { ++res; } } res.writeln; }