結果

問題 No.771 しおり
ユーザー 👑 obakyanobakyan
提出日時 2019-07-04 23:23:39
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 1,097 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 76,448 KB
最終ジャッジ日時 2023-10-19 10:39:32
合計ジャッジ時間 6,569 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max

local n = io.read("*n")
local a, b, c = {}, {}, {}
local tot = 1
for i = 1, n do
  a[i], b[i] = io.read("*n", "*n")
  c[i] = b[i] - a[i]
  tot = tot * 2
end

local function dotask(stage, curtask)
  local nexttask = {}
  for i = 1, n do
    nexttask[i] = {}
  end
  local mul = 1
  for i = 1, n do
    for used, val in pairs(curtask[i]) do
      local tmp = used
      for j = 1, n do
        if tmp % 2 == 0 and i ~= j then
          if nexttask[j][used + mul] == nil then
            nexttask[j][used + mul] = mma(val, c[i] + a[j])
          else
            nexttask[j][used + mul] = mmi(mma(val, c[i] + a[j]), nexttask[j][used + mul])
          end
        end
        tmp = mfl(tmp / 2)
      end
    end
    mul = mul * 2
  end
  return nexttask
end

local tasks = {}
for i = 1, n do
  tasks[i] = {}
  tasks[i][0] = 0
end
for i = 2, n do
  tasks = dotask(i, tasks)
end
local min = 1000 * 100
for i = 1, n do
  for k, v in pairs(tasks[i]) do
    -- print(i, k, v)
    min = mmi(min, v)
  end
end
print(min)
0