結果

問題 No.137 貯金箱の焦り
ユーザー MahdiSiyamMahdiSiyam
提出日時 2023-04-30 19:04:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,073 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 200,712 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 23:41:36
合計ジャッジ時間 3,608 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,248 KB
testcase_01 AC 12 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 12 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = 1000 +5;
const ll oo = 1234567891LL;

int n;
ll m;
int pos[N];
int a[N];
ll save[65][N];

ll dp(int i,int c)
{
	if(i==5)
		return c==0;
	ll &ret=save[i][c];
	if(ret!=-1) return ret;
	ret=0;
	for(int j=0;j<N;j++)
	{
		int now = c+j;
		if(((now >>0)&1) == ((m>>i)&1))
		{
			ll x = dp(i+1,now/2);
			ret = (ret + pos[j] * x)%oo;
		}
	}
	return ret;
}

void solve()
{
	cin>>n>>m;
	pos[0]=1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		for(int j=N-1;j>=a[i];j--)
			pos[j]=(pos[j]+pos[j-a[i]])%oo;
	}
	for(int i=0;i<=m;i++)
		debug(i,pos[i]);
	memset(save,-1,sizeof(save));
	cout<<dp(0,0)<<endl;
}
/*

*/

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