結果
問題 | No.1739 Princess vs. Dragoness (& AoE) |
ユーザー |
👑 |
提出日時 | 2021-11-13 20:39:39 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,056 bytes |
コンパイル時間 | 437 ms |
コンパイル使用メモリ | 5,504 KB |
実行使用メモリ | 17,312 KB |
最終ジャッジ日時 | 2024-11-27 22:02:30 |
合計ジャッジ時間 | 63,522 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 TLE * 8 |
ソースコード
local mfl, mce = math.floor, math.ceillocal mmi, mma = math.min, math.maxlocal bls, brs = bit.lshift, bit.rshiftlocal Heapq = {}Heapq.create = function(self, lt)self.lt = ltself.cnt = 0self.t = {}endHeapq.push = function(self, v)local hqlt = self.ltlocal hqt = self.tlocal c = self.cnt + 1self.cnt = chqt[c] = vwhile 1 < c dolocal p = brs(c, 1)if hqlt(hqt[c], hqt[p]) thenhqt[c], hqt[p] = hqt[p], hqt[c]c = pelsebreakendendendHeapq.pop = function(self)local hqlt = self.ltlocal hqt = self.tlocal ret = hqt[1]local c = self.cnthqt[1] = hqt[c]c = c - 1self.cnt = clocal p = 1while true dolocal d1, d2 = p * 2, p * 2 + 1if c < d1 then breakelseif c < d2 thenif hqlt(hqt[d1], hqt[p]) thenhqt[d1], hqt[p] = hqt[p], hqt[d1]endbreakelseif hqlt(hqt[d1], hqt[d2]) thenif hqlt(hqt[d1], hqt[p]) thenhqt[d1], hqt[p] = hqt[p], hqt[d1]p = d1else breakendelseif hqlt(hqt[d2], hqt[p]) thenhqt[d2], hqt[p] = hqt[p], hqt[d2]p = d2else breakendendendendreturn retendHeapq.new = function(lt)local obj = {}setmetatable(obj, {__index = Heapq})obj:create(lt)return objendlocal n = io.read("*n")local a, b = io.read("*n", "*n")local x, y = io.read("*n", "*n")local hs = {}for i = 1, n dotable.insert(hs, io.read("*n"))endlocal function solve(z)local hq = Heapq.new(function(c, d) return c > d end)for i = 1, n dolocal h = hs[i]hq:push(h)endfor i = 1, a dolocal v = hq:pop()if v <= z thenhq:push(v) breakendv = mma(z, v - x)hq:push(v)endlocal tot = 0for i = 1, n dotot = tot + mma(0, hq:pop() - z)endreturn tot <= b * yendlocal min, max = -1, 1000000007while 1 < max - min dolocal mid = mfl((min + max) / 2)if solve(mid) thenmax = midelsemin = midendendprint(max)