結果

問題 No.158 奇妙なお使い
ユーザー 沙耶花沙耶花
提出日時 2021-11-02 22:15:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,377 ms / 5,000 ms
コード長 1,571 bytes
コンパイル時間 4,786 ms
コンパイル使用メモリ 261,280 KB
実行使用メモリ 49,876 KB
最終ジャッジ日時 2024-04-20 08:58:03
合計ジャッジ時間 8,641 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
46,900 KB
testcase_01 AC 34 ms
47,200 KB
testcase_02 AC 23 ms
46,852 KB
testcase_03 AC 22 ms
46,992 KB
testcase_04 AC 2,377 ms
47,016 KB
testcase_05 AC 24 ms
46,900 KB
testcase_06 AC 23 ms
47,140 KB
testcase_07 AC 24 ms
46,908 KB
testcase_08 AC 23 ms
47,028 KB
testcase_09 AC 25 ms
47,036 KB
testcase_10 AC 25 ms
46,936 KB
testcase_11 AC 24 ms
46,972 KB
testcase_12 AC 24 ms
46,824 KB
testcase_13 AC 24 ms
46,888 KB
testcase_14 AC 30 ms
46,988 KB
testcase_15 AC 62 ms
47,088 KB
testcase_16 AC 46 ms
46,996 KB
testcase_17 AC 234 ms
47,360 KB
testcase_18 AC 43 ms
46,944 KB
testcase_19 AC 24 ms
47,172 KB
testcase_20 AC 33 ms
47,056 KB
testcase_21 AC 25 ms
46,968 KB
testcase_22 AC 25 ms
47,044 KB
testcase_23 AC 26 ms
46,872 KB
testcase_24 AC 24 ms
46,832 KB
testcase_25 AC 23 ms
47,028 KB
testcase_26 AC 35 ms
47,212 KB
testcase_27 AC 24 ms
47,168 KB
testcase_28 AC 156 ms
47,252 KB
testcase_29 AC 24 ms
47,204 KB
testcase_30 AC 197 ms
49,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int dp[11][101][10001];

int main(){	
	
	vector<int> a(3);
	rep(i,3)cin>>a[i];
	
	int db;
	cin>>db;
	vector<int> b(3);
	rep(i,3)cin>>b[i];
	
	int dc;
	cin>>dc;
	vector<int> c(3);
	rep(i,3)cin>>c[i];
	
	rep(i,11){
		rep(j,101){
			rep(k,10001)dp[i][j][k] = -Inf;
		}
	}
	
	priority_queue<pair<int,vector<int>>> Q;
	dp[a[0]][a[1]][a[2]] = 0;
	
	Q.emplace(a[0]*1000+a[1]*100+a[2],a);
	
	while(Q.size()>0){
		vector<int> t = Q.top().second;
		Q.pop();
		rep(i,t[0]+1){
			rep(j,t[1]+1){
				if(i*1000+j*100>db)break;
				int k = db - i*1000 - j*100;
				if(t[2]<k)continue;
				
				auto nt = t;
				nt[0] -= i;
				nt[1] -= j;
				nt[2] -= k;
				rep(k,3)nt[k] += b[k];
				if(dp[nt[0]][nt[1]][nt[2]]==-Inf)Q.emplace(nt[0]*1000+nt[1]*100+nt[2],nt);
				dp[nt[0]][nt[1]][nt[2]] = max(dp[nt[0]][nt[1]][nt[2]], dp[t[0]][t[1]][t[2]]+1);
			}
		}
		
		rep(i,t[0]+1){
			rep(j,t[1]+1){
				if(i*1000+j*100>dc)break;
				int k = dc - i*1000 - j*100;
				if(t[2]<k)continue;
				
				auto nt = t;
				nt[0] -= i;
				nt[1] -= j;
				nt[2] -= k;
				rep(k,3)nt[k] += c[k];
				if(dp[nt[0]][nt[1]][nt[2]]==-Inf)Q.emplace(nt[0]*1000+nt[1]*100+nt[2],nt);
				dp[nt[0]][nt[1]][nt[2]] = max(dp[nt[0]][nt[1]][nt[2]], dp[t[0]][t[1]][t[2]]+1);
			}
		}
		
	}
	
	int ans =0;
	rep(i,11){
		rep(j,101){
			rep(k,10001)ans = max(ans,dp[i][j][k]);
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
	
}
0