結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー yuruhiyayuruhiya
提出日時 2021-01-26 16:53:49
言語 Crystal
(1.11.2)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 23,303 ms
コンパイル使用メモリ 259,288 KB
実行使用メモリ 6,300 KB
最終ジャッジ日時 2023-09-13 13:25:37
合計ジャッジ時間 28,222 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,404 KB
testcase_02 AC 3 ms
4,432 KB
testcase_03 AC 2 ms
4,428 KB
testcase_04 AC 3 ms
4,484 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,436 KB
testcase_07 AC 2 ms
4,436 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 7 ms
5,004 KB
testcase_10 AC 6 ms
5,016 KB
testcase_11 AC 6 ms
5,008 KB
testcase_12 AC 39 ms
5,180 KB
testcase_13 AC 144 ms
5,628 KB
testcase_14 AC 23 ms
5,180 KB
testcase_15 AC 23 ms
5,212 KB
testcase_16 AC 36 ms
5,480 KB
testcase_17 AC 56 ms
6,032 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,396 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 6 ms
5,020 KB
testcase_22 AC 4 ms
5,088 KB
testcase_23 AC 5 ms
4,988 KB
testcase_24 AC 204 ms
6,160 KB
testcase_25 AC 209 ms
6,236 KB
testcase_26 AC 205 ms
6,196 KB
testcase_27 AC 206 ms
6,120 KB
testcase_28 AC 192 ms
6,032 KB
testcase_29 AC 195 ms
6,160 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 3 ms
4,448 KB
testcase_32 AC 4 ms
5,048 KB
testcase_33 AC 5 ms
4,920 KB
testcase_34 AC 6 ms
4,908 KB
testcase_35 AC 222 ms
5,664 KB
testcase_36 AC 233 ms
5,732 KB
testcase_37 AC 242 ms
5,712 KB
testcase_38 AC 236 ms
5,656 KB
testcase_39 AC 234 ms
5,688 KB
testcase_40 AC 205 ms
6,152 KB
testcase_41 AC 198 ms
6,080 KB
testcase_42 AC 206 ms
6,300 KB
testcase_43 AC 203 ms
6,192 KB
testcase_44 AC 200 ms
6,080 KB
testcase_45 AC 205 ms
6,164 KB
testcase_46 AC 191 ms
6,152 KB
testcase_47 AC 189 ms
6,208 KB
testcase_48 AC 192 ms
6,144 KB
testcase_49 AC 189 ms
6,028 KB
testcase_50 AC 190 ms
6,188 KB
testcase_51 AC 195 ms
6,140 KB
testcase_52 AC 160 ms
6,244 KB
testcase_53 AC 200 ms
6,012 KB
testcase_54 AC 177 ms
6,156 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 = [{0, I}] + [{I, I}] * k
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