結果

問題 No.27 板の準備
ユーザー kurenai3110
提出日時 2016-09-27 22:33:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 687 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 58,408 KB
最終ジャッジ日時 2025-03-25 07:56:00
合計ジャッジ時間 1,413 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:25: error: ‘INT32_MAX’ was not declared in this scope
   15 |         long long ans = INT32_MAX;
      |                         ^~~~~~~~~
main.cpp:4:1: note: ‘INT32_MAX’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    3 | #include <algorithm>
  +++ |+#include <cstdint>
    4 | using namespace std;

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long DP[61];

int main()
{
	vector<int>v(4);
	cin >> v[0] >> v[1] >> v[2] >> v[3];
	sort(v.begin(), v.end());


	long long ans = INT32_MAX;
	for (int i = 1; i < 29; i++)for (int j = i + 1; j < 30; j++)for (int k = j + 1; k < 31; k++) {
		for (int l = 0; l < 61; l++)DP[l] = INT32_MAX;
		DP[0] = 0;
		for (int l = 0; l < 31; l++) {
			if (DP[l] == INT32_MAX)continue;
			DP[l + i] = min(DP[l + i], DP[l] + 1);
			DP[l + j] = min(DP[l + j], DP[l] + 1);
			DP[l + k] = min(DP[l + k], DP[l] + 1);
		}
		ans = min(ans, DP[v[0]] + DP[v[1]] + DP[v[2]] + DP[v[3]]);
	}

	cout << ans << endl;

    return 0;
}
0