結果

問題 No.137 貯金箱の焦り
ユーザー chineristACchineristAC
提出日時 2022-02-27 00:43:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,490 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 305,844 KB
最終ジャッジ日時 2023-09-18 05:50:22
合計ジャッジ時間 9,617 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
78,864 KB
testcase_01 AC 122 ms
74,728 KB
testcase_02 AC 150 ms
80,924 KB
testcase_03 AC 119 ms
74,472 KB
testcase_04 AC 214 ms
81,976 KB
testcase_05 AC 120 ms
74,308 KB
testcase_06 AC 185 ms
81,512 KB
testcase_07 AC 158 ms
81,148 KB
testcase_08 AC 161 ms
81,324 KB
testcase_09 AC 190 ms
81,932 KB
testcase_10 AC 158 ms
81,076 KB
testcase_11 AC 120 ms
74,472 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class DualSegmentTree:
    def __init__(self, n, segfunc, ide_ele):
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num

    def update(self,l,r,x):
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                self.tree[l] = self.segfunc(self.tree[l],x)
                l += 1
            if r & 1:
                self.tree[r-1] = self.segfunc(self.tree[r-1],x)
            l >>= 1
            r >>= 1

    def __getitem__(self,idx):
        idx += self.num
        res = self.ide_ele
        while idx:
            res = self.segfunc(res,self.tree[idx])
            idx>>=1
        return res

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

mod = 1234567891

N,M = mi()
A = li()

dp = {0:1}
for k in range(60):
    t = 2**k
    for j in range(N):
        ndp = {s:dp[s] for s in dp}
        for s in dp:
            if s+A[j]*t > M:
                continue
            if s+A[j]*t not in ndp:
                ndp[s+A[j]*t] = 0
            ndp[s+A[j]*t] += dp[s]
            ndp[s+A[j]*t] %= mod
        dp = ndp
    dp = {s:dp[s] for s in dp if s%(2*t)==M%(2*t)}

if M in dp:
    print(dp[M])
else:
    print(0)
0