結果
問題 | No.27 板の準備 |
ユーザー |
![]() |
提出日時 | 2015-07-14 20:27:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 538 ms |
コンパイル使用メモリ | 57,208 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 10:35:18 |
合計ジャッジ時間 | 1,383 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; #define loop(i,a,b) for(int i=(a);i<int(b);i++) #define rep(i,b) loop(i,0,b) int const inf = 100000000; int solve(int x, int y, int z, int a, int b, int c, int d){ int dp[32]; rep(i,32) dp[i] = inf; dp[0] = 0; for(int e : {x,y,z}) loop(i,e,32) dp[i] = min(dp[i],dp[i-e]+1); return dp[a]+dp[b]+dp[c]+dp[d]; } int main(){ int a,b,c,d; cin >> a >> b >> c >> d; int ans = inf; for(int i=1;i<=30;i++){ loop(j,1,i){ loop(k,1,j){ ans = min(ans,solve(i,j,k,a,b,c,d)); } } } cout << ans << endl; }