import sequtils,algorithm,math,tables,sugar import sets,intsets,queues,heapqueue,bitops,strutils proc printf(formatstr: cstring){.header: "", varargs.} proc putchar_unlocked(c:char){. importc:"putchar_unlocked",header: "" .} proc printInt(a:int32) = template div10(a:int32) : int32 = cast[int32]((0x1999999A * cast[int64](a)) shr 32) template put(n:int32) = putchar_unlocked("0123456789"[n]) if a < 10: put(a) return if a < 100: let a1 = a.div10 (put(a1);put(a-a1*10)) return if a < 1000: let a1 = a.div10 let a2 = a1.div10 put(a2) put(a1-a2*10) put(a-a1*10) return if a < 10000: let a1 = a.div10 let a2 = a1.div10 let a3 = a2.div10 put(a3) put(a2-a3*10) put(a1-a2*10) put(a-a1*10) return if a < 100000: let a1 = a.div10 let a2 = a1.div10 let a3 = a2.div10 let a4 = a3.div10 put(a4) put(a3-a2*10) put(a2-a3*10) put(a1-a2*10) put(a-a1*10) return proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int32 = while true: let k = getchar_unlocked() if k < '0': break result = 10.int32 * result + k.ord.int32 - '0'.ord.int32 proc scanName(): string = result = "" while true: let k = getchar_unlocked() if k == ' ': return result &= k proc calcScore(star:int32,ac:int32):int32 = 50 * star + (50 * star) * 5 div (4 + ac) let n = scan() let L = newSeqWith(n,scan()) var AC = newSeqWith(n,1.int32) type User = ref object name: string scores : seq[int32] lastSubmit: int32 sum:int32 proc newUser(name:string): User = new(result) result.name = name result.scores = newSeq[int32](n) proc update(self:var User,pID:int32,score:int32,lastSumbit:int32) = self.sum += score self.lastSubmit = lastSumbit self.scores[pID] = score var maxID = 0 var userIDs = newTable[string,int]() var users = newSeq[User]() for i in 0.int32..