結果

問題 No.2232 Miser's Gift
ユーザー s0919s0919
提出日時 2023-03-04 00:20:53
言語 Crystal
(1.11.2)
結果
AC  
実行時間 612 ms / 2,000 ms
コード長 414 bytes
コンパイル時間 17,713 ms
コンパイル使用メモリ 280,432 KB
実行使用メモリ 91,684 KB
最終ジャッジ日時 2023-10-18 03:56:01
合計ジャッジ時間 39,881 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 604 ms
91,684 KB
testcase_04 AC 284 ms
91,684 KB
testcase_05 AC 67 ms
14,404 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 123 ms
4,520 KB
testcase_08 AC 606 ms
91,680 KB
testcase_09 AC 602 ms
91,680 KB
testcase_10 AC 608 ms
91,680 KB
testcase_11 AC 606 ms
91,680 KB
testcase_12 AC 602 ms
91,680 KB
testcase_13 AC 600 ms
91,684 KB
testcase_14 AC 612 ms
91,684 KB
testcase_15 AC 606 ms
91,684 KB
testcase_16 AC 607 ms
91,684 KB
testcase_17 AC 604 ms
91,684 KB
testcase_18 AC 609 ms
91,684 KB
testcase_19 AC 606 ms
91,684 KB
testcase_20 AC 599 ms
91,684 KB
testcase_21 AC 601 ms
91,684 KB
testcase_22 AC 604 ms
91,684 KB
testcase_23 AC 592 ms
91,680 KB
testcase_24 AC 595 ms
91,680 KB
testcase_25 AC 588 ms
91,680 KB
testcase_26 AC 591 ms
91,680 KB
testcase_27 AC 592 ms
91,680 KB
testcase_28 AC 506 ms
91,680 KB
testcase_29 AC 502 ms
91,680 KB
testcase_30 AC 496 ms
91,680 KB
testcase_31 AC 513 ms
91,680 KB
testcase_32 AC 507 ms
91,680 KB
testcase_33 AC 597 ms
91,684 KB
testcase_34 AC 604 ms
91,684 KB
testcase_35 AC 603 ms
91,684 KB
testcase_36 AC 607 ms
91,684 KB
testcase_37 AC 605 ms
91,684 KB
testcase_38 AC 9 ms
4,348 KB
testcase_39 AC 10 ms
4,348 KB
testcase_40 AC 9 ms
4,348 KB
testcase_41 AC 9 ms
4,348 KB
testcase_42 AC 10 ms
4,348 KB
testcase_43 AC 10 ms
4,348 KB
testcase_44 AC 9 ms
4,348 KB
testcase_45 AC 10 ms
4,348 KB
testcase_46 AC 10 ms
4,348 KB
testcase_47 AC 10 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 3 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 3 ms
4,348 KB
testcase_53 AC 3 ms
4,348 KB
testcase_54 AC 3 ms
4,348 KB
testcase_55 AC 3 ms
4,348 KB
testcase_56 AC 3 ms
4,348 KB
testcase_57 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, w = read_line.split.map(&.to_i)
u = Array.new(n){0}
v = Array.new(n){0}

n.times do |i|
  u[i], v[i] = read_line.split.map(&.to_i)
end

d = Array.new(n+1){Array.new(w+1, 0_i64)}
d[0][0] = 0_i64

n.times do |i|
  (w+1).times do |j|
    if j - u[i] >= 0
      d[i+1][j] = [d[i][j], d[i][j-u[i]] + v[i]].max
    else
      d[i+1][j] = d[i][j]
    end
  end
end

w.times {|i| 
    puts d[n][w] - d[n][w-i-1] + 1 
}
0