結果

問題 No.137 貯金箱の焦り
ユーザー sugim48sugim48
提出日時 2015-01-26 00:46:15
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,339 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 95,116 KB
実行使用メモリ 12,092 KB
最終ジャッジ日時 2023-09-05 06:51:37
合計ジャッジ時間 7,984 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { ll B, T, F, P; };

ll MOD = 1234567891;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 10;

ll f(ll M, int l, int r, vector<int>& A, unordered_map<ll, ll>& mp) {
	ll unko = (M * 50 + l) * 50 + r;
	if (mp.count(unko)) return mp[unko];
	if (M < 0) return 0;
	if (M == 0) return 1;
	if (l >= r) return 0;
	int N = A.size();
	ll sum = 0;
	for (int m = l; m < r; m++)
		for (int i = 0; i < A[m]; i++)
			if (M / 2 - i >= 0 && M - (M / 2 - i + A[m]) >= 0)
				sum += (f(M / 2 - i, l, m + 1, A, mp) * f(M - (M / 2 - i + A[m]), m, r, A, mp)) % MOD;
	return mp[unko] = sum % MOD;
}

int main() {
	int N; ll M; cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	unordered_map<ll, ll> mp;
	cout << f(M, 0, N, A, mp) << endl;
}
0