結果

問題 No.771 しおり
ユーザー 👑 obakyanobakyan
提出日時 2019-07-06 15:14:40
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,057 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 7,112 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-26 00:01:44
合計ジャッジ時間 2,031 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,372 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,372 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,372 KB
testcase_10 AC 1 ms
4,372 KB
testcase_11 AC 1 ms
4,372 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,372 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 6 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

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 = {}, 0, {}
for i = 1, n do
  a[i], b = io.read("*n", "*n")
  c[i] = b - a[i]
end

local function dotask(stage, curtask)
  local nexttask = {}
  for i = 1, n do
    nexttask[i] = {}
  end
  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 then
          local nt = nexttask[j][used]
          if nt then
            nexttask[j][used] = mmi(mma(val, c[i] + a[j]), nt)
          else
            nexttask[j][used] = mma(val, c[i] + a[j])
          end
        else
          tmp = tmp - 1
        end
        tmp = tmp / 2
      end
    end
  end
  return nexttask
end

local tasks = {}
local tmp = 1
for i = 1, n do
  tasks[i] = {}
  tasks[i][tmp] = 0
  tmp = tmp * 2
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