結果

問題 No.2549 Paint Eggs
ユーザー sepa38
提出日時 2023-11-19 21:32:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 1,331 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 147,552 KB
最終ジャッジ日時 2024-09-26 06:25:04
合計ジャッジ時間 16,885 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
n, m, k = map(int, input().split())
c = list(map(lambda x: int(x)-1, input().split()))
a = list(map(int, input().split()))
d = dict()
for i in range(m):
  d[i] = a[i] * k
for i in range(k):
  d[c[i]] -= a[c[i]]
ans = min(d.values())
# print(d)
h = []
for i in d.keys():
  heapq.heappush(h, m*d[i]+i)
for i in range(n-k):
  while h:
    cost, idx = divmod(heapq.heappop(h), m)
    if d[idx] == cost:
      ans = min(ans, cost)
      heapq.heappush(h, m*cost+idx)
      break
print(ans)
0