結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,260 KB
testcase_01 AC 87 ms
15,392 KB
testcase_02 WA -
testcase_03 AC 85 ms
15,240 KB
testcase_04 WA -
testcase_05 AC 83 ms
15,048 KB
testcase_06 AC 82 ms
15,248 KB
testcase_07 AC 88 ms
15,172 KB
testcase_08 AC 86 ms
15,256 KB
testcase_09 AC 86 ms
15,172 KB
testcase_10 AC 86 ms
15,200 KB
testcase_11 AC 83 ms
15,180 KB
testcase_12 AC 82 ms
15,072 KB
testcase_13 AC 82 ms
15,268 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 146 ms
15,684 KB
testcase_18 AC 84 ms
15,064 KB
testcase_19 AC 88 ms
15,064 KB
testcase_20 AC 90 ms
15,072 KB
testcase_21 AC 84 ms
15,152 KB
testcase_22 WA -
testcase_23 AC 90 ms
15,260 KB
testcase_24 WA -
testcase_25 AC 138 ms
15,540 KB
testcase_26 AC 104 ms
15,248 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 119 ms
15,640 KB
testcase_30 WA -
testcase_31 AC 109 ms
15,248 KB
testcase_32 WA -
testcase_33 AC 87 ms
15,120 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 225 ms
16,724 KB
testcase_40 AC 82 ms
15,168 KB
testcase_41 AC 82 ms
15,048 KB
testcase_42 AC 85 ms
15,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:40: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def f(a,b)
	if b==nil
		return true
	end
	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+1).map{Array.new(k+1,[])}

n.times{|i|
	m=i+1
	break if m>=dp.size
	dp[m][1]=[m,[m]]
}
(1..(k-1)).each{|i|
	d.times{|j|
		if dp[j][i]==[]
			next
		end
		e0=dp[j][i][0]
		e1=dp[j][i][1]
		((e1.last+1)..n).each{|add|
			e2=e0+add
			if dp.size<=e2
				break
			end
			e3=Marshal.load(Marshal.dump(e1))
			e3<<add
			if f(e3,dp[e2][i+1][1])==true
				dp[e2][i+1]=[e2,e3]
			end
		}
	}
}
if dp[d][k][1]==nil
	puts -1
else
	puts dp[d][k][1]*" "
end
0