結果

問題 No.27 板の準備
ユーザー fiordfiord
提出日時 2015-07-18 00:55:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 149,908 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 18:46:55
合計ジャッジ時間 2,787 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:7: warning: ‘make’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   int make;
       ^~~~

ソースコード

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 t=0;t<4;t++){
		vector<int> data;
		int make;
		for(int i=0;i<4;i++){
			if(i!=t)	data.push_back(v[i]);
			else 	make=v[i];
		}
		vector<int> dp(make+1,1000);
		dp[0]=0;
		for(int i=0;i<=make;i++){
			for(int j=0;j<3;j++){
				if(i+data[j]<=make){
					dp[i+data[j]]=min(dp[i+data[j]],dp[i]+1);
				}
			}
		}
		ans=min(ans,dp[make]+3);
	}
	cout<<ans<<endl;
	return 0;
}
0