結果

問題 No.27 板の準備
ユーザー snrnsidysnrnsidy
提出日時 2021-05-07 04:34:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,105 bytes
コンパイル時間 1,242 ms
コンパイル使用メモリ 128,320 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 20:04:58
合計ジャッジ時間 2,666 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <unordered_set>
#include <fstream>
#include <random>

using namespace std;

int dp[31];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c, d;
	int res = 1e9;
	cin >> a >> b >> c >> d;

	for (int i = 1; i <= 30; i++)
	{
		for (int j = i + 1; j <= 30; j++)
		{
			for (int k = j + 1; k <= 30; k++)
			{
				for (int l = 0; l <= 30; l++)
				{
					dp[l] = 1e5;
				}
				dp[i] = 1;
				dp[j] = 1;
				dp[k] = 1;
				for (int x = 1; x <= 30; x++)
				{
					if (dp[x] != 1e5) continue;
					for (int y = 1; y < x; y++)
					{
						dp[x] = min(dp[x], dp[y] + dp[x - y]);
					}
				}
				res = min(res, dp[a] + dp[b] + dp[c] + dp[d]);
			}
		}
	}

	cout << res << '\n';

	return 0;
}

0