結果

問題 No.137 貯金箱の焦り
ユーザー pekempeypekempey
提出日時 2016-02-18 09:20:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 907 bytes
コンパイル時間 1,434 ms
コンパイル使用メモリ 161,792 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-23 18:03:23
合計ジャッジ時間 4,469 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,348 KB
testcase_01 AC 4 ms
4,348 KB
testcase_02 AC 20 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 20 ms
4,348 KB
testcase_05 AC 8 ms
4,348 KB
testcase_06 AC 19 ms
4,348 KB
testcase_07 AC 14 ms
4,348 KB
testcase_08 AC 15 ms
4,348 KB
testcase_09 AC 20 ms
4,348 KB
testcase_10 AC 13 ms
4,348 KB
testcase_11 AC 11 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 24 ms
4,348 KB
testcase_14 AC 157 ms
4,348 KB
testcase_15 AC 138 ms
4,348 KB
testcase_16 AC 142 ms
4,348 KB
testcase_17 AC 85 ms
4,348 KB
testcase_18 AC 133 ms
4,348 KB
testcase_19 AC 158 ms
4,348 KB
testcase_20 AC 13 ms
4,348 KB
testcase_21 AC 105 ms
4,348 KB
testcase_22 AC 39 ms
4,348 KB
testcase_23 AC 34 ms
4,348 KB
testcase_24 AC 74 ms
4,348 KB
testcase_25 AC 124 ms
4,348 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[30303], dp1[30303];
	dp0[0] = 1;
	while (m > 0) {
		memset(dp1, 0, sizeof(dp1));
		rep(i, n) repr(j, 30303) if (j + a[i] < 30303) {
			(dp0[j + a[i]] += dp0[j]) %= mod;
		}
		rep(j, 30303) if (j % 2 == (m & 1)) {
			(dp1[j / 2] += dp0[j]) %= mod;
		}
		m /= 2;
		swap(dp0, dp1);
	}
	cout << dp0[0] << endl;

	return 0;
}
0