結果

問題 No.1701 half price
ユーザー U S
提出日時 2021-10-08 22:24:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 313 ms / 3,000 ms
コード長 940 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 77,196 KB
最終ジャッジ日時 2024-07-23 04:56:22
合計ジャッジ時間 2,826 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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