結果

問題 No.27 板の準備
ユーザー cormorancormoran
提出日時 2016-09-27 21:54:59
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,265 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 160,388 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 05:47:48
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

const int INF = 200;

class Solver {
  public:
    bool solve() {
        vector<int> V(4); cin >> V;
        int ans = INF;
        repeat(a, 1, 30 + 1) repeat(b, 1, a + 1) repeat(c, 1, b + 1) {
            int sum = 0;
            for(int v : V) {
                vector<int> dp(v + 1, INF);
                dp[0] = 0;                
                rep(i, dp.size()) {
                    if(i + a <= dp.size()) set_min(dp[i + a], dp[i] + 1);
                    if(i + b <= dp.size()) set_min(dp[i + b], dp[i] + 1);
                    if(i + c <= dp.size()) set_min(dp[i + c], dp[i] + 1);
                }
                sum += dp[v];
            }
            set_min(ans, sum);
        }
        assert(ans < INF);
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0