結果

問題 No.137 貯金箱の焦り
ユーザー MahdiSiyamMahdiSiyam
提出日時 2023-04-30 23:16:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 235 ms / 5,000 ms
コード長 912 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 166,288 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 01:55:10
合計ジャッジ時間 4,860 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,248 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 24 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 27 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 25 ms
5,376 KB
testcase_07 AC 18 ms
5,376 KB
testcase_08 AC 19 ms
5,376 KB
testcase_09 AC 27 ms
5,376 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 9 ms
5,376 KB
testcase_12 AC 235 ms
5,376 KB
testcase_13 AC 34 ms
5,376 KB
testcase_14 AC 232 ms
5,376 KB
testcase_15 AC 203 ms
5,376 KB
testcase_16 AC 207 ms
5,376 KB
testcase_17 AC 123 ms
5,376 KB
testcase_18 AC 195 ms
5,376 KB
testcase_19 AC 233 ms
5,376 KB
testcase_20 AC 13 ms
5,376 KB
testcase_21 AC 154 ms
5,376 KB
testcase_22 AC 51 ms
5,376 KB
testcase_23 AC 45 ms
5,376 KB
testcase_24 AC 106 ms
5,376 KB
testcase_25 AC 181 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
typedef pair<int,int> pii;
#define ALL(x) x.begin(),x.end()

const int N = 50000 +15;
const ll oo = 1234567891LL;

int n;
ll m;
int sum = 0;
int a[N];
ll dp[N];
void solve()
{
	debug(oo*oo);
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	dp[0]=1;
	while(m)
	{
		for(int i=0;i<n;i++)
			for(int j=N-1;j>=a[i];j--)
				dp[j] = (dp[j] + dp[j-a[i]])%oo;
		for(int i=0;i<N;i++)
		{
			int x = i*2+(m&1);
			if(x<N)
				dp[i] = dp[x];
			else dp[i]=0;
		}
		m/=2;
	}
	cout<<dp[0]<<"\n";

}
/*

*/

int32_t main()
{
#ifndef LOKAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int T=1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

		   	  	 			 	  			    		  	 	
0