結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー 👑 obakyanobakyan
提出日時 2019-05-12 23:07:00
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,510 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 4,700 KB
最終ジャッジ日時 2023-09-19 06:43:32
合計ジャッジ時間 2,028 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 18 ms
4,376 KB
testcase_06 AC 39 ms
4,444 KB
testcase_07 AC 15 ms
4,380 KB
testcase_08 AC 20 ms
4,376 KB
testcase_09 AC 33 ms
4,456 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 26 ms
4,376 KB
testcase_14 AC 33 ms
4,380 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 10 ms
4,380 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 52 ms
4,676 KB
testcase_20 AC 38 ms
4,700 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 7 ms
4,380 KB
testcase_23 AC 11 ms
4,380 KB
testcase_24 AC 33 ms
4,380 KB
testcase_25 AC 46 ms
4,448 KB
testcase_26 AC 18 ms
4,376 KB
testcase_27 AC 16 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ior = io.input()
local n = ior:read("*n")
local level, clearCount = {}, {}
for i = 1, n do
  level[i] = ior:read("*n")
  clearCount[i] = 0
end
local eps = 1.0e-6
local function getscore(pNo)
  local tmp = clearCount[pNo] + 1
  clearCount[pNo] = tmp
  return math.floor(eps + 50 * level[pNo] * (1 + 1 / (0.8 + 0.2 * tmp)))
end

local Hito = {}
Hito.setScore = function(self, problemNo, time)
  local score = getscore(problemNo)
  self.score[problemNo] = score
  self.totscore = self.totscore + score
  self.time = time
end
Hito.dump = function(self, rank)
  io.write(rank .. " " .. self.name)
  for i = 1, n do
    io.write(" " .. self.score[i])
  end
  io.write(" " .. self.totscore .. "\n")
end

local function Hitolt(x, y)
  if(x.totscore == y.totscore) then
    return x.time < y.time
  else
    return x.totscore > y.totscore
  end
end

Hito.new = function(name)
  local obj = {}
  obj.name = name
  obj.score = {}
  for i = 1, n do obj.score[i] = 0 end
  obj.totscore = 0
  obj.time = -1
  setmetatable(obj, {__index = Hito, __lt = Hitolt})
  return obj
end

local hitolist = {}
local hitomap = {}
local datanum = ior:read("*n", "*l")
for i = 1, datanum do
  local txt = ior:read()
  local name, p = txt:match("(%w+) (%w)")
  local problemNo = string.byte(p) - 64
  if(hitomap[name] == nil) then
    table.insert(hitolist, Hito.new(name))
    hitomap[name] = #hitolist
  end
  hitolist[hitomap[name]]:setScore(problemNo, i)
end
table.sort(hitolist)
for i = 1, #hitolist do
  hitolist[i]:dump(i)
end
0