結果

問題 No.137 貯金箱の焦り
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-04 14:47:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 145,552 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 04:17:22
合計ジャッジ時間 12,679 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
4,380 KB
testcase_01 AC 39 ms
4,376 KB
testcase_02 AC 75 ms
4,380 KB
testcase_03 AC 22 ms
4,376 KB
testcase_04 AC 273 ms
4,376 KB
testcase_05 AC 273 ms
4,376 KB
testcase_06 AC 273 ms
4,384 KB
testcase_07 AC 183 ms
4,376 KB
testcase_08 AC 183 ms
4,376 KB
testcase_09 AC 272 ms
4,376 KB
testcase_10 AC 165 ms
4,376 KB
testcase_11 AC 22 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 895 ms
4,376 KB
testcase_14 AC 898 ms
4,380 KB
testcase_15 AC 769 ms
4,380 KB
testcase_16 AC 788 ms
4,380 KB
testcase_17 AC 469 ms
4,376 KB
testcase_18 AC 753 ms
4,380 KB
testcase_19 AC 880 ms
4,376 KB
testcase_20 AC 39 ms
4,376 KB
testcase_21 AC 577 ms
4,380 KB
testcase_22 AC 182 ms
4,380 KB
testcase_23 AC 165 ms
4,376 KB
testcase_24 AC 415 ms
4,380 KB
testcase_25 AC 682 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define MAX 30000

long long dp[MAX];

long long mod = 1234567891;

int main() {
	int N;
	long long M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	dp[0] = 1;
	for (int t = 60; t >= 0; t--)
	{
		int add = (M >> t) % 2;
		for (int i = MAX - 1; i >= 0; i--)
		{
			if (i % 2 == add) dp[i] = dp[i / 2];
			else dp[i] = 0;
		}
		for (int i = 0; i < N; i++)
		{
			for (int j = A[i]; j < MAX; j++)
			{
				dp[j - A[i]] += dp[j];
				dp[j - A[i]] %= mod;
			}
		}
	}
	cout << dp[0] << endl;
}
0