結果

問題 No.158 奇妙なお使い
ユーザー wing3196wing3196
提出日時 2015-02-27 00:18:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 72,380 KB
実行使用メモリ 814,964 KB
最終ジャッジ日時 2023-09-06 03:01:57
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 19 ms
46,840 KB
testcase_04 RE -
testcase_05 AC 19 ms
46,880 KB
testcase_06 AC 19 ms
46,948 KB
testcase_07 MLE -
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 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
using namespace std;

int A[3],B[3],C[3],Db,Dc,memo[11][101][10001];

int dfs(int m[3],int dep){
	//printf("%d,%d,%d %d\n",m[0],m[1],m[2],dep);
	if(memo[m[0]][m[1]][m[2]]!=-1) return memo[m[0]][m[1]][m[2]];
	int ans=0;
	for(int i=0;i<=m[0];i++){
		for(int j=0;j<=m[1];j++){
			for(int k=0;k<=m[2];k++){
				int sum = i*1000+j*100+k;
				int latte[3] = {m[0]-i+B[0],m[1]-j+B[1],m[2]-k+B[2]};
				if(sum==Db) ans = max(ans,dfs(latte,dep+1));
				if(sum==Dc) ans = max(ans,dfs(latte,dep+1));
			}
		}
	}
	ans++;
	memo[m[0]][m[1]][m[2]] = ans;
	return ans;
}

int main(){
	fill(memo[0][0],memo[0][0]+11*101*10001,-1);
	for(int i=0;i<3;i++) cin>>A[i];
	cin>>Db;
	for(int i=0;i<3;i++) cin>>B[i];
	cin>>Dc;
	for(int i=0;i<3;i++) cin>>C[i];
	printf("%d\n",dfs(A,0)-1);
	return 0;
}
0