結果
問題 |
No.2549 Paint Eggs
|
ユーザー |
![]() |
提出日時 | 2023-11-21 17:57:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 180 ms / 2,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 115,824 KB |
最終ジャッジ日時 | 2024-09-26 07:16:13 |
合計ジャッジ時間 | 9,123 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 |
ソースコード
def solve(n, m, k, c_list, a_list): # 色ごとに何個あるかを管理 count_col = [0] * (m + 1) count_col_max = [0] * (m + 1) # 最初のk個 for i in range(k): count_col[c_list[i]] += 1 for c in range(m + 1): count_col_max[c] = count_col[c] # 1ずつずらす for i in range(k, n): c_right = c_list[i] c_left = c_list[i - k] count_col[c_right] += 1 count_col[c_left] -= 1 count_col_max[c_right] = max(count_col_max[c_right], count_col[c_right]) # 集計 r_list = [a_list[i] * (k - count_col_max[i + 1]) for i in range(m)] res = min(r_list) return res def main(): n, m, k = map(int, input().split()) c_list = list(map(int, input().split())) a_list = list(map(int, input().split())) res = solve(n, m, k, c_list, a_list) print(res) def test(): assert solve(5, 3, 3, [1, 2, 1, 3, 2], [10, 10, 10]) == 10 assert solve(5, 3, 3, [1, 1, 1, 1, 1], [10, 10, 10]) == 0 if __name__ == "__main__": test() main()