結果

問題 No.27 板の準備
ユーザー yuma25689yuma25689
提出日時 2015-11-11 01:48:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 923 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2023-08-27 04:09:21
合計ジャッジ時間 4,081 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
7,976 KB
testcase_01 AC 151 ms
7,796 KB
testcase_02 AC 150 ms
7,804 KB
testcase_03 AC 151 ms
7,804 KB
testcase_04 AC 149 ms
7,772 KB
testcase_05 AC 152 ms
7,948 KB
testcase_06 AC 150 ms
7,784 KB
testcase_07 AC 150 ms
7,840 KB
testcase_08 AC 151 ms
7,764 KB
testcase_09 AC 151 ms
7,848 KB
testcase_10 AC 150 ms
7,892 KB
testcase_11 AC 152 ms
7,780 KB
testcase_12 AC 152 ms
7,852 KB
testcase_13 AC 148 ms
7,884 KB
testcase_14 AC 152 ms
7,792 KB
testcase_15 AC 152 ms
7,792 KB
testcase_16 AC 150 ms
7,884 KB
testcase_17 AC 149 ms
7,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 入力

# V0 V1 V2 V3
# 指定された板の長さが4つ(V0,V1,V2,V3)与えられます。
# 1<=V0,V1,V2,V3<=30の整数であり、Vi=Vj (0<=i,j<=3)となる場合もあります。

# 出力

# 必要な板の数を文字列で最後に改行を含め出力してく
INF=10e9
plate_max=30

plateTarget = input().split()

res=INF

for plateA in range(1,plate_max+1):
	for plateB in range(plateA+1,plate_max+1):
		for plateC in range(plateB+1,plate_max+1):
			# このプレートABCの組み合わせでの、最小枚数を求める
			# メモ用配列初期化
			minCount=[ INF for i in range(plate_max+1)]
			minCount[0]=0
			arr=[plateA,plateB,plateC]
			for plateLen in arr:
				for i in range(int(plateLen),plate_max+1):
					minCount[i]=min(minCount[i],minCount[i-int(plateLen)]+1)

			# 4枚分集計
			tmp=0
			for target in plateTarget:
				tmp+=minCount[int(target)]

			res=min(res,tmp)

print(res)
0