結果

問題 No.137 貯金箱の焦り
ユーザー pekempeypekempey
提出日時 2016-02-18 09:21:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 271 ms / 5,000 ms
コード長 907 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 145,912 KB
実行使用メモリ 4,392 KB
最終ジャッジ日時 2023-08-07 18:23:34
合計ジャッジ時間 5,076 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 6 ms
4,380 KB
testcase_02 AC 33 ms
4,376 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 32 ms
4,380 KB
testcase_05 AC 12 ms
4,376 KB
testcase_06 AC 30 ms
4,380 KB
testcase_07 AC 22 ms
4,380 KB
testcase_08 AC 23 ms
4,380 KB
testcase_09 AC 31 ms
4,392 KB
testcase_10 AC 20 ms
4,376 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 271 ms
4,380 KB
testcase_13 AC 38 ms
4,380 KB
testcase_14 AC 267 ms
4,376 KB
testcase_15 AC 234 ms
4,380 KB
testcase_16 AC 240 ms
4,376 KB
testcase_17 AC 144 ms
4,380 KB
testcase_18 AC 226 ms
4,380 KB
testcase_19 AC 266 ms
4,376 KB
testcase_20 AC 21 ms
4,376 KB
testcase_21 AC 178 ms
4,380 KB
testcase_22 AC 64 ms
4,376 KB
testcase_23 AC 57 ms
4,380 KB
testcase_24 AC 125 ms
4,380 KB
testcase_25 AC 208 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
typedef long long ll;

int main() {
	ll n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	const ll mod = 1234567891;
	static ll dp0[50505], dp1[50505];
	dp0[0] = 1;
	while (m > 0) {
		memset(dp1, 0, sizeof(dp1));
		rep(i, n) repr(j, 50505) if (j + a[i] < 50505) {
			(dp0[j + a[i]] += dp0[j]) %= mod;
		}
		rep(j, 50505) if (j % 2 == (m & 1)) {
			(dp1[j / 2] += dp0[j]) %= mod;
		}
		m /= 2;
		swap(dp0, dp1);
	}
	cout << dp0[0] << endl;

	return 0;
}
0