結果

問題 No.27 板の準備
ユーザー BantakoBantako
提出日時 2018-06-16 20:08:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 620 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 166,080 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 04:54:52
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 28) - 1;
int MOD = 1e9+7;
main(){
    int V[4],num[3];
    rep(i,0,4)cin >> V[i];
    int ans = INF;
    rep(i,1,31)rep(j,i+1,31)rep(k,j+1,31){
        num[0] = i;
        num[1] = j;
        num[2] = k;

        vector<int> dp(31,INF);
        dp[0] = 0;
        rep(l,0,31)rep(m,0,3){
            if(l < num[m])continue;
            dp[l] = min(dp[l], dp[l - num[m]] + 1);
        }
        ans = min(ans, dp[V[0]] + dp[V[1]] + dp[V[2]] + dp[V[3]] );
    }
    cout << ans << endl;
}
0