結果

問題 No.1701 half price
ユーザー U SU S
提出日時 2021-10-08 22:24:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 372 ms / 3,000 ms
コード長 940 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 80,824 KB
最終ジャッジ日時 2023-09-30 10:50:14
合計ジャッジ時間 4,671 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
74,332 KB
testcase_01 AC 113 ms
74,232 KB
testcase_02 AC 155 ms
80,448 KB
testcase_03 AC 115 ms
73,924 KB
testcase_04 AC 150 ms
80,772 KB
testcase_05 AC 120 ms
78,716 KB
testcase_06 AC 372 ms
80,592 KB
testcase_07 AC 336 ms
80,824 KB
testcase_08 AC 113 ms
74,000 KB
testcase_09 AC 115 ms
73,776 KB
testcase_10 AC 112 ms
74,340 KB
testcase_11 AC 115 ms
74,092 KB
testcase_12 AC 112 ms
74,084 KB
testcase_13 AC 114 ms
74,000 KB
testcase_14 AC 114 ms
74,016 KB
testcase_15 AC 113 ms
74,096 KB
testcase_16 AC 111 ms
74,068 KB
testcase_17 AC 203 ms
80,620 KB
testcase_18 AC 121 ms
79,092 KB
testcase_19 AC 127 ms
79,060 KB
testcase_20 AC 114 ms
73,712 KB
testcase_21 AC 124 ms
79,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#import sys
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
def mps(A):return [tuple(map(int, input().split())) for _ in range(A)]
import math
import bisect
import heapq
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e20)
mod = 998244353

n,w = mp()
a = lmp()
ans = 0
for i in range(1,1<<n):
    cnt = 0
    lst = []
    for j in range(n):
        if i & 1<<j == 1<<j:
            cnt += a[j]
            lst.append(a[j]//2)
    if cnt < w:continue
    dif = cnt-w
    #print(lst,dif)
    flag = False
    for j in range(1<<len(lst)):
        c = 0
        for k in range(len(lst)):
            if j & 1<<k == 1<<k:
                c += lst[k]
        if c == dif:
            flag = True
    if flag:ans += 1

print(ans)
0