結果

問題 No.771 しおり
ユーザー 👑 obakyanobakyan
提出日時 2019-07-04 23:31:31
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,158 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 67,368 KB
最終ジャッジ日時 2023-09-29 12:56:12
合計ジャッジ時間 33,984 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 151 ms
8,900 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 947 ms
30,772 KB
testcase_26 AC 14 ms
4,376 KB
testcase_27 AC 151 ms
8,884 KB
testcase_28 AC 372 ms
17,768 KB
testcase_29 AC 151 ms
8,884 KB
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 27 ms
4,380 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 27 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 6 ms
4,380 KB
testcase_38 AC 27 ms
4,380 KB
testcase_39 AC 6 ms
4,380 KB
testcase_40 AC 1,014 ms
30,832 KB
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 151 ms
8,948 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, {}
local tot = 1
for i = 1, n do
  a[i], b = io.read("*n", "*n")
  c[i] = b - 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 then
          if i ~= j then
            local nt = nexttask[j][used + mul]
            if nt then
              nexttask[j][used + mul] = mmi(mma(val, c[i] + a[j]), nt)
            else
              nexttask[j][used + mul] = mma(val, c[i] + a[j])
            end
          end
        else
          tmp = tmp - 1
        end
        tmp = 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