結果

問題 No.2686 商品券の使い道
ユーザー tomeruntomerun
提出日時 2024-03-20 22:38:13
言語 Crystal
(1.11.2)
結果
TLE  
実行時間 -
コード長 571 bytes
コンパイル時間 12,463 ms
コンパイル使用メモリ 293,800 KB
実行使用メモリ 25,920 KB
最終ジャッジ日時 2024-03-20 22:38:56
合計ジャッジ時間 37,787 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,352 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 433 ms
6,912 KB
testcase_03 AC 453 ms
6,912 KB
testcase_04 AC 504 ms
6,912 KB
testcase_05 AC 449 ms
6,912 KB
testcase_06 AC 438 ms
6,912 KB
testcase_07 AC 475 ms
6,912 KB
testcase_08 AC 432 ms
6,912 KB
testcase_09 AC 470 ms
6,912 KB
testcase_10 AC 484 ms
6,912 KB
testcase_11 AC 1,280 ms
6,912 KB
testcase_12 AC 560 ms
6,912 KB
testcase_13 AC 1,187 ms
6,912 KB
testcase_14 AC 1,109 ms
6,912 KB
testcase_15 AC 842 ms
6,912 KB
testcase_16 AC 1,197 ms
6,912 KB
testcase_17 AC 873 ms
6,912 KB
testcase_18 AC 783 ms
6,912 KB
testcase_19 AC 913 ms
6,912 KB
testcase_20 AC 1,214 ms
6,912 KB
testcase_21 AC 1,224 ms
6,912 KB
testcase_22 AC 573 ms
6,912 KB
testcase_23 AC 666 ms
6,912 KB
testcase_24 AC 1,043 ms
6,912 KB
testcase_25 AC 441 ms
6,912 KB
testcase_26 AC 687 ms
6,912 KB
testcase_27 AC 1,135 ms
6,912 KB
testcase_28 AC 442 ms
6,912 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
evil_random20_1.txt -- -
evil_random20_2.txt -- -
evil_random20_3.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, q = read_line.split.map(&.to_i)
abs = Array.new(n) { read_line.split.map(&.to_i64) }
sum_a = Array.new(1 << n, 0i64)
sum_b = Array.new(1 << n, 0i64)
1.upto((1 << n) - 1) do |i|
  mi = i.trailing_zeros_count
  sum_a[i] = sum_a[i - (1 << mi)] + abs[mi][0]
  sum_b[i] = sum_b[i - (1 << mi)] + abs[mi][1]
end
ans = 0i64
(1 << n).times do |t|
  if sum_a[t] <= m || sum_a[t] <= q
    ans = {ans, sum_b[t]}.max
  end
  s = t
  while s > 0
    s2 = t ^ s
    if sum_a[s] <= m && sum_a[s2] <= q
      ans = {ans, sum_b[t]}.max
    end
    s = (s - 1) & t
  end
end
puts ans
0