結果

問題 No.27 板の準備
ユーザー tubo28tubo28
提出日時 2015-07-14 20:27:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 655 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 60,000 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 03:27:33
合計ジャッジ時間 1,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0