結果

問題 No.158 奇妙なお使い
ユーザー fiordfiord
提出日時 2015-08-24 00:06:04
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,196 bytes
コンパイル時間 1,954 ms
コンパイル使用メモリ 152,324 KB
実行使用メモリ 814,692 KB
最終ジャッジ日時 2023-09-25 16:39:28
合計ジャッジ時間 6,448 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 27 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 MLE -
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 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int dp[10][100][10000];
tuple<int,int,int> ok(int a,int th,int hu,int on){
	int dig=min(th,a/1000);
	th-=dig;	a-=dig*1000;
	dig=min(hu,a/100);
	hu-=dig;	a-=dig*100;
	dig=min(on,a);
	on-=dig;	a-=dig;
	if(a>0)	return make_tuple(-1,-1,-1);
	return make_tuple(th,hu,on);
}
int main(){
	int a[3];	cin>>a[0]>>a[1]>>a[2];
	int db;	cin>>db;
	int b[3];	cin>>b[0]>>b[1]>>b[2];
	int dc;	cin>>dc;
	int c[3];	cin>>c[0]>>c[1]>>c[2];
	int ans=0;
	queue<tuple<int,int,int> > q;
	q.push(make_tuple(a[0],a[1],a[2]));
	tuple<int,int,int> n;
	while(!q.empty()){
		n=q.front();	q.pop();
		int th=get<0>(n);
		int hu=get<1>(n);
		int on=get<2>(n);
		n=ok(db,th,hu,on);
		if(get<0>(n)!=-1){
			int nt=get<0>(n)+b[0];
			int nh=get<1>(n)+b[1];
			int no=get<2>(n)+b[2];
			dp[nt][nh][no]=max(dp[nt][nh][no],dp[th][hu][on]+1);
			q.push(make_tuple(nt,nh,no));
			ans=max(ans,dp[nt][nh][no]);
		}
		n=ok(dc,th,hu,on);
		if(get<0>(n)!=-1){
			int nt=get<0>(n)+c[0];
			int nh=get<1>(n)+c[1];
			int no=get<2>(n)+c[2];
			dp[nt][nh][no]=max(dp[nt][nh][no],dp[th][hu][on]+1);
			q.push(make_tuple(nt,nh,no));
			ans=max(ans,dp[nt][nh][no]);
		}
	}
	cout<<ans<<endl;
	return 0;
}
0