結果

問題 No.2549 Paint Eggs
ユーザー sepa38sepa38
提出日時 2023-11-19 21:41:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,539 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 155,048 KB
最終ジャッジ日時 2023-11-19 21:41:42
合計ジャッジ時間 28,350 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
64,856 KB
testcase_01 AC 64 ms
70,500 KB
testcase_02 AC 50 ms
64,844 KB
testcase_03 AC 56 ms
66,376 KB
testcase_04 AC 50 ms
64,576 KB
testcase_05 AC 59 ms
68,064 KB
testcase_06 AC 80 ms
77,172 KB
testcase_07 AC 63 ms
70,928 KB
testcase_08 AC 47 ms
61,332 KB
testcase_09 AC 65 ms
72,568 KB
testcase_10 AC 821 ms
129,676 KB
testcase_11 AC 407 ms
147,452 KB
testcase_12 AC 361 ms
111,008 KB
testcase_13 AC 832 ms
123,016 KB
testcase_14 AC 306 ms
120,244 KB
testcase_15 AC 212 ms
80,312 KB
testcase_16 AC 563 ms
117,788 KB
testcase_17 AC 343 ms
103,108 KB
testcase_18 AC 286 ms
100,204 KB
testcase_19 AC 352 ms
113,096 KB
testcase_20 AC 1,101 ms
145,472 KB
testcase_21 AC 1,539 ms
155,048 KB
testcase_22 AC 617 ms
145,596 KB
testcase_23 AC 1,126 ms
145,240 KB
testcase_24 AC 535 ms
145,468 KB
testcase_25 AC 512 ms
145,100 KB
testcase_26 AC 589 ms
144,752 KB
testcase_27 AC 915 ms
145,088 KB
testcase_28 AC 593 ms
145,140 KB
testcase_29 AC 1,104 ms
145,780 KB
testcase_30 AC 500 ms
145,472 KB
testcase_31 AC 922 ms
145,340 KB
testcase_32 AC 1,107 ms
149,980 KB
testcase_33 AC 1,162 ms
145,340 KB
testcase_34 AC 890 ms
144,752 KB
testcase_35 AC 504 ms
145,492 KB
testcase_36 AC 938 ms
145,464 KB
testcase_37 AC 1,174 ms
147,308 KB
testcase_38 AC 916 ms
144,980 KB
testcase_39 AC 993 ms
145,340 KB
testcase_40 AC 606 ms
145,472 KB
testcase_41 AC 542 ms
145,240 KB
testcase_42 AC 560 ms
145,244 KB
testcase_43 AC 520 ms
145,240 KB
testcase_44 AC 568 ms
145,236 KB
権限があれば一括ダウンロードができます

ソースコード

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):
  d[c[i]] += a[c[i]]
  d[c[i+k]] -= a[c[i+k]]
  heapq.heappush(h, m*d[c[i]]+c[i])
  heapq.heappush(h, m*d[c[i+k]]+c[i+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