結果

問題 No.771 しおり
ユーザー 👑 obakyanobakyan
提出日時 2019-07-06 15:19:55
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,125 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 68,080 KB
最終ジャッジ日時 2023-10-22 00:35:14
合計ジャッジ時間 28,680 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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
      used = used + 1
      local mul = 1
      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
        used = used + mul
        mul = mul * 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
    min = mmi(min, v)
  end
end
print(min)
0