結果

問題 No.1701 half price
ユーザー ysys
提出日時 2022-03-07 02:06:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 359 ms / 3,000 ms
コード長 422 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 77,188 KB
最終ジャッジ日時 2023-09-28 19:06:31
合計ジャッジ時間 4,191 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,424 KB
testcase_01 AC 77 ms
71,336 KB
testcase_02 AC 121 ms
77,188 KB
testcase_03 AC 79 ms
71,472 KB
testcase_04 AC 117 ms
76,860 KB
testcase_05 AC 88 ms
76,492 KB
testcase_06 AC 355 ms
76,952 KB
testcase_07 AC 359 ms
77,124 KB
testcase_08 AC 80 ms
71,568 KB
testcase_09 AC 81 ms
71,352 KB
testcase_10 AC 81 ms
71,416 KB
testcase_11 AC 78 ms
71,408 KB
testcase_12 AC 82 ms
71,388 KB
testcase_13 AC 81 ms
71,284 KB
testcase_14 AC 82 ms
71,356 KB
testcase_15 AC 79 ms
71,456 KB
testcase_16 AC 79 ms
71,480 KB
testcase_17 AC 175 ms
77,144 KB
testcase_18 AC 91 ms
76,188 KB
testcase_19 AC 94 ms
76,464 KB
testcase_20 AC 77 ms
71,312 KB
testcase_21 AC 343 ms
76,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, W = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, 1 << N):
  C = []
  res = 0
  add = 0
  for j in range(N):
    if i & 1 << j:
      res += a[j]
      C.append(j)
  if res == W:
    add = 1

  L = len(C)
  for j in range(1 << L):
    res2 = res
    for k in range(L):
      if j & 1 << k:
        res2 -= a[C[k]] // 2

    if res2 == W:
      add = 1

  ans += add
print(ans)
0