結果

問題 No.27 板の準備
ユーザー togatogatogatoga
提出日時 2015-04-20 00:02:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,671 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 91,688 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 02:10:54
合計ジャッジ時間 1,883 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-9;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
vector<int> V;
int dp[50];
int main() {
  for (int i = 0; i < 4; i++) {
    int x;
    cin >> x;
    V.push_back(x);
  }
  int res = INF;
  for (int A = 1; A <= 30; A++) {
    for (int B = A + 1; B <= 30; B++) {
      for (int C = B + 1; C <= 30; C++) {
        fill(dp, dp + 50, INF);
        dp[A] = 1;
        dp[B] = 1;
        dp[C] = 1;
        // cout << A << " " << B << " " << C << endl;
        for (int k = 1; k <= 30; k++) {
          if (k - A >= 0 and dp[k - A] != INF) {
            dp[k] = min(dp[k], dp[k - A] + 1);
          }
          if (k - B >= 0 and dp[k - B] != INF) {
            dp[k] = min(dp[k], dp[k - B] + 1);
          }
          if (k - C >= 0 and dp[k - C] != INF) {
            dp[k] = min(dp[k], dp[k - C] + 1);
          }
        }
        int tmp = 0;
        for (int i = 0; i < V.size(); i++) {
          tmp += dp[V[i]];
        }
        res = min(res, tmp);
      }
    }
  }
  cout << res << endl;
  return 0;
}
0