結果

問題 No.158 奇妙なお使い
ユーザー pekempeypekempey
提出日時 2016-12-22 23:28:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,747 ms / 5,000 ms
コード長 1,097 bytes
コンパイル時間 1,747 ms
コンパイル使用メモリ 165,584 KB
実行使用メモリ 26,404 KB
最終ジャッジ日時 2023-09-12 09:13:45
合計ジャッジ時間 5,698 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
25,052 KB
testcase_01 AC 14 ms
25,028 KB
testcase_02 AC 9 ms
25,044 KB
testcase_03 AC 8 ms
25,048 KB
testcase_04 AC 1,747 ms
26,404 KB
testcase_05 AC 9 ms
25,000 KB
testcase_06 AC 9 ms
25,000 KB
testcase_07 AC 9 ms
25,048 KB
testcase_08 AC 9 ms
25,040 KB
testcase_09 AC 9 ms
25,148 KB
testcase_10 AC 10 ms
25,012 KB
testcase_11 AC 9 ms
25,064 KB
testcase_12 AC 9 ms
25,128 KB
testcase_13 AC 8 ms
25,172 KB
testcase_14 AC 15 ms
25,064 KB
testcase_15 AC 26 ms
25,124 KB
testcase_16 AC 19 ms
25,128 KB
testcase_17 AC 101 ms
25,020 KB
testcase_18 AC 13 ms
25,180 KB
testcase_19 AC 9 ms
25,064 KB
testcase_20 AC 11 ms
25,168 KB
testcase_21 AC 9 ms
25,360 KB
testcase_22 AC 9 ms
26,188 KB
testcase_23 AC 10 ms
25,004 KB
testcase_24 AC 9 ms
25,092 KB
testcase_25 AC 9 ms
25,204 KB
testcase_26 AC 20 ms
25,004 KB
testcase_27 AC 9 ms
25,168 KB
testcase_28 AC 151 ms
25,052 KB
testcase_29 AC 11 ms
25,056 KB
testcase_30 AC 330 ms
25,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

short dp[11][101][10001];
int db;
int dc;
int b1000, b100, b1;
int c1000, c100, c1;

int f(int a, int b, int c) {
	if (dp[a][b][c] != -1) {
		return dp[a][b][c];
	}
	int ret = 0;
	for (int i = db % 100; i <= min(c, db); i += 100) {
		for (int j = 0; i + j * 100 <= db && j <= b; j++) {
			if ((db - i - j * 100) % 1000 != 0) {
				continue;
			}
			int k = (db - i - j * 100) / 1000;
			if (k > a) {
				continue;
			}
			ret = max(ret, 1 + f(a - k + b1000, b - j + b100, c - i + b1));
		}
	}
	for (int i = dc % 100; i <= min(c, dc); i += 100) {
		for (int j = 0; i + j * 100 <= dc && j <= b; j++) {
			if ((dc - i - j * 100) % 1000 != 0) {
				continue;
			}
			int k = (dc - i - j * 100) / 1000;
			if (k > a) {
				continue;
			}
			ret = max(ret, 1 + f(a - k + c1000, b - j + c100, c - i + c1));
		}
	}
	return dp[a][b][c] = ret;
}

int main() {
	int a1000, a100, a1;
	cin >> a1000 >> a100 >> a1;
	cin >> db;
	cin >> b1000 >> b100 >> b1;
	cin >> dc;
	cin >> c1000 >> c100 >> c1;
	memset(dp, -1, sizeof(dp));
	cout << f(a1000, a100, a1) << endl;
}
0