結果

問題 No.137 貯金箱の焦り
ユーザー titia
提出日時 2025-07-24 03:26:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 999 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 67,700 KB
最終ジャッジ日時 2025-07-24 03:26:44
合計ジャッジ時間 14,263 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))

mod=1234567891
DP=[0]*50001
DP[0]=1

for i in range(65):
    for a in A:
        for j in range(50000,-1,-1):
            if j+a<50001:
                DP[j+a]=(DP[j+a]+DP[j])%mod

    #print(DP[:50],M)

    if M%2==0:
        for j in range(0,50001):
            if j%2==0:
                DP[j//2]=DP[j]
                if j!=0:
                    DP[j]=0
            else:
                DP[j]=0
    else:
        for j in range(0,50001):
            if j%2==1:
                DP[j//2]=DP[j]
                DP[j]=0
            else:
                DP[j]=0

    #print(DP[:50])
    M//=2

print(DP[0])
0