結果
問題 | No.1736 Princess vs. Dragoness |
ユーザー |
👑 |
提出日時 | 2021-11-13 13:21:39 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 1,688 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 08:08:13 |
合計ジャッジ時間 | 1,602 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
local 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 hq = Heapq.new(function(c, d) return c > d end)for i = 1, n dolocal h = io.read("*n")hq:push(h)endfor i = 1, a dolocal v = hq:pop()v = mma(0, v - x)hq:push(v)endlocal tot = 0for i = 1, n dotot = tot + hq:pop()endprint(tot <= b * y and "Yes" or "No")