結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー yuruhiyayuruhiya
提出日時 2021-01-26 08:00:40
言語 Crystal
(1.11.2)
結果
AC  
実行時間 1,312 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 17,754 ms
コンパイル使用メモリ 259,576 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-09-13 13:24:28
合計ジャッジ時間 55,367 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 2 ms
4,444 KB
testcase_02 AC 3 ms
4,704 KB
testcase_03 AC 3 ms
4,472 KB
testcase_04 AC 3 ms
4,416 KB
testcase_05 AC 2 ms
4,436 KB
testcase_06 AC 3 ms
4,608 KB
testcase_07 AC 3 ms
4,428 KB
testcase_08 AC 3 ms
4,608 KB
testcase_09 AC 28 ms
5,388 KB
testcase_10 AC 17 ms
5,120 KB
testcase_11 AC 17 ms
5,176 KB
testcase_12 AC 219 ms
6,280 KB
testcase_13 AC 815 ms
6,548 KB
testcase_14 AC 116 ms
6,404 KB
testcase_15 AC 133 ms
5,872 KB
testcase_16 AC 208 ms
5,396 KB
testcase_17 AC 260 ms
5,904 KB
testcase_18 AC 2 ms
4,468 KB
testcase_19 AC 3 ms
4,388 KB
testcase_20 AC 3 ms
4,420 KB
testcase_21 AC 17 ms
5,832 KB
testcase_22 AC 8 ms
5,460 KB
testcase_23 AC 10 ms
5,400 KB
testcase_24 AC 1,274 ms
6,420 KB
testcase_25 AC 1,263 ms
6,372 KB
testcase_26 AC 1,260 ms
6,336 KB
testcase_27 AC 1,294 ms
6,428 KB
testcase_28 AC 1,295 ms
6,332 KB
testcase_29 AC 1,298 ms
6,344 KB
testcase_30 AC 2 ms
4,420 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 9 ms
5,196 KB
testcase_33 AC 13 ms
5,512 KB
testcase_34 AC 26 ms
5,828 KB
testcase_35 AC 1,235 ms
6,408 KB
testcase_36 AC 1,271 ms
6,400 KB
testcase_37 AC 1,304 ms
6,360 KB
testcase_38 AC 1,291 ms
6,420 KB
testcase_39 AC 1,281 ms
6,356 KB
testcase_40 AC 1,288 ms
6,324 KB
testcase_41 AC 1,312 ms
6,276 KB
testcase_42 AC 1,291 ms
6,276 KB
testcase_43 AC 1,266 ms
6,492 KB
testcase_44 AC 1,281 ms
6,416 KB
testcase_45 AC 1,295 ms
6,416 KB
testcase_46 AC 1,224 ms
6,356 KB
testcase_47 AC 1,296 ms
6,392 KB
testcase_48 AC 1,294 ms
6,500 KB
testcase_49 AC 1,299 ms
6,336 KB
testcase_50 AC 1,309 ms
6,272 KB
testcase_51 AC 1,259 ms
6,352 KB
testcase_52 AC 1,210 ms
6,424 KB
testcase_53 AC 1,261 ms
6,376 KB
testcase_54 AC 1,264 ms
6,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = read_line.split.map(&.to_i)
p, d = (1..n).map { read_line.split.map(&.to_i) }.sort.reverse.transpose
I = -10**9
dp = [[I, I]] * -~k
dp[0][0] = 0
n.times { |i|
  dp = (0..k).map { |j|
    [{dp[j][0], dp[j][1] + d[i]}.max, {dp[j][1], j >= p[i] ? dp[j - p[i]][0] + d[i] : I}.max]
  }
}
puts dp.max_of(&.max)
0