結果

問題 No.27 板の準備
ユーザー fiordfiord
提出日時 2015-07-18 01:05:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 148,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:00:36
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> v(4);
	for(int i=0;i<4;i++)	cin>>v[i];
	sort(v.begin(),v.end());
	int ans=1000;
	for(int i=1;i<=30;i++){
		for(int j=i+1;j<=30;j++){
			for(int k=j+1;k<=30;k++){
				vector<int> dp(32,1000);
				dp[0]=0;
				for(int s=0;s<=30;s++){
					if(s+i<=30)	dp[s+i]=min(dp[s+i],dp[s]+1);
					if(s+j<=30)	dp[s+j]=min(dp[s+j],dp[s]+1);
					if(s+k<=30)	dp[s+k]=min(dp[s+k],dp[s]+1);
				}
				ans=min(ans,dp[v[0]]+dp[v[1]]+dp[v[2]]+dp[v[3]]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
0