結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
17,536 KB
testcase_01 AC 92 ms
12,288 KB
testcase_02 AC 89 ms
12,160 KB
testcase_03 AC 93 ms
12,288 KB
testcase_04 AC 93 ms
12,032 KB
testcase_05 AC 89 ms
12,160 KB
testcase_06 AC 97 ms
12,288 KB
testcase_07 AC 103 ms
13,568 KB
testcase_08 AC 100 ms
12,928 KB
testcase_09 AC 98 ms
12,672 KB
testcase_10 AC 102 ms
13,184 KB
testcase_11 AC 881 ms
128,896 KB
testcase_12 AC 323 ms
42,240 KB
testcase_13 AC 661 ms
92,800 KB
testcase_14 AC 1,575 ms
271,360 KB
testcase_15 AC 552 ms
69,376 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(N) {|i|
	0.upto(K) {|j|
		dp[i][j][0] = -Float::INFINITY
		dp[i][j][1] = ""
	}
}
dp[0][0][0] = 0

1.upto(N) {|i|
	0.upto([i,K].min) {|j|
		dp[i][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