結果
| 問題 |
No.158 奇妙なお使い
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-11-02 22:15:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3,107 ms / 5,000 ms |
| コード長 | 1,571 bytes |
| コンパイル時間 | 5,599 ms |
| コンパイル使用メモリ | 256,600 KB |
| 最終ジャッジ日時 | 2025-01-25 10:34:58 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#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;
}
沙耶花