結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー 小野寺健小野寺健
提出日時 2021-10-30 12:55:14
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 534 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 370,592 KB
最終ジャッジ日時 2024-04-16 16:16:38
合計ジャッジ時間 10,306 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
19,104 KB
testcase_01 AC 86 ms
12,160 KB
testcase_02 AC 86 ms
12,288 KB
testcase_03 AC 87 ms
12,032 KB
testcase_04 AC 88 ms
12,288 KB
testcase_05 AC 89 ms
12,288 KB
testcase_06 AC 90 ms
12,160 KB
testcase_07 AC 98 ms
13,312 KB
testcase_08 AC 96 ms
12,672 KB
testcase_09 AC 93 ms
12,544 KB
testcase_10 AC 94 ms
13,056 KB
testcase_11 AC 759 ms
123,008 KB
testcase_12 AC 283 ms
39,040 KB
testcase_13 AC 575 ms
89,600 KB
testcase_14 AC 1,361 ms
267,264 KB
testcase_15 AC 471 ms
63,744 KB
testcase_16 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split(" ").map{|s| s.to_i}

a = gets.split(" ").map{|s| s.to_i}
b = gets.split(" ").map{|s| s.to_i}

dp = Array.new(N+1) {Array.new(K+1) {Array.new(2)}}

0.upto(K) {|j|
	dp[0][j][0] = -Float::INFINITY
	dp[0][j][1] = ""
}

dp[0][0][0] = 0

1.upto(N) {|i|
	0.upto(K) {|j|
		dp[i][j][0] = -Float::INFINITY
		dp[i][j][1] = ""
	}
	0.upto([i,K].min) {|j|
		dp[i][j] = [j > 0 ? [dp[i-1][j-1][0] + a[i-1], dp[i-1][j-1][1] + "A"] : [-Float::INFINITY, ""],
		[dp[i-1][j][0] + b[i-1], dp[i-1][j][1] + "B"]].max
	}
}

puts dp[N][K][1]
0