結果

問題 No.115 遠足のおやつ
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-28 09:16:04
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 751 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 11,596 KB
実行使用メモリ 45,160 KB
最終ジャッジ日時 2023-09-07 19:17:48
合計ジャッジ時間 7,090 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
45,160 KB
testcase_01 AC 103 ms
16,280 KB
testcase_02 AC 107 ms
15,440 KB
testcase_03 AC 87 ms
15,064 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:50: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def f(a,b)
	return true if b==[]
	a.size.times{|i|
		return a[i]<b[i] if a[i]!=b[i]
	}
	return false
end

n,d,k=gets.split.map{|e| e.to_i}
dp = Array.new(d+2).map{Array.new(k+2).map{Array.new(n+2,[])}}

n.times{|i|
	m2=i+1
	break if d<m2
	break if n<m2
	dp[m2][1][m2]=[m2]
}
(1..(k-1)).each{|i|
	d.times{|j|
		e0=j
		n.times{|j1|
			if dp[j][i][j1]==[]
				next
			end
			e0=j
			e1=dp[j][i][j1]
			((j1+1)..n).each{|add|
				e2=e0+add
				if dp.size<=e2
					break
				end
				e3=Marshal.load(Marshal.dump(e1))
				e3<<add
				if dp[e2][i+1][add]==[] || f(e3,dp[e2][i+1][add])==true
					dp[e2][i+1][add]=e3
				end
			}
		}
	}
}

ans=[]
n.times{|i|
	m2=i+1
	if f(dp[d][k][m2],ans)
		ans=dp[d][k][m2]
	end
}
if ans==[]
	puts -1
else
	puts ans*" "
end
0