結果

問題 No.27 板の準備
ユーザー kotatsugamekotatsugame
提出日時 2019-10-15 06:48:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 66,748 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 23:23:09
合計ジャッジ時間 1,983 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
using namespace std;
int X[4];
int dp[31];
main()
{
	for(int i=0;i<4;i++)cin>>X[i];
	long ans=1e9;
	for(int A=1;A<=30;A++)for(int B=A+1;B<=30;B++)for(int C=B+1;C<=30;C++)
	{
		for(int i=1;i<=30;i++)dp[i]=1e9;
		for(int i=1;i<=30;i++)
		{
			if(i>=A)dp[i]=min(dp[i],dp[i-A]+1);
			if(i>=B)dp[i]=min(dp[i],dp[i-B]+1);
			if(i>=C)dp[i]=min(dp[i],dp[i-C]+1);
		}
		long now=0;
		for(int i=0;i<4;i++)now+=dp[X[i]];
		if(ans>now)ans=now;
	}
	cout<<ans<<endl;
}
0