結果

問題 No.2549 Paint Eggs
コンテスト
ユーザー sepa38
提出日時 2023-11-19 21:32:52
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 497 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 294 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 155,064 KB
最終ジャッジ日時 2026-04-13 09:39:15
合計ジャッジ時間 13,684 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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