結果

問題 No.27 板の準備
ユーザー A8pfA8pf
提出日時 2018-10-30 01:37:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,060 bytes
コンパイル時間 1,125 ms
コンパイル使用メモリ 144,612 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:55:55
合計ジャッジ時間 2,038 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll=long long;

int dp[80]; // cannot write down description of DP only English...

int main()
{
    int v[4];
    int ans=1e8-1;
    for(int i=0;i<4;i++)
        cin>>v[i];
    
    // from now DP
    for(int a=1;a<31;a++)
    {
        for(int b=a+1;b<31;b++)
        {
            for(int c=b+1;c<31;c++)
            {
                fill(dp,dp+80,1e8-1);
                dp[0]=0;
                for(int i=1;i<31;i++)
                {
                    for(int j=0;j<31;j++)
                    {
                        if(dp[j]==i-1)
                        {
                            dp[j+a]=min(dp[j+a],i);
                            dp[j+b]=min(dp[j+b],i);
                            dp[j+c]=min(dp[j+c],i);
                        }
                    }
                }
                int cnt=0;
                for(int i=0;i<4;i++)
                    cnt+=dp[v[i]];
                ans=min(ans,cnt);
            }
        }
    }
    // end of DP

    cout<<ans<<endl;
    return 0;
}
0