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 function getscore(pNo) local tmp = clearCount[pNo] + 1 clearCount[pNo] = tmp return math.floor(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() print(txt) 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