結果

問題 No.2549 Paint Eggs
コンテスト
ユーザー yuriko32
提出日時 2026-03-13 01:46:56
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 739 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,326 ms
コンパイル使用メモリ 213,284 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2026-03-13 01:48:48
合計ジャッジ時間 105,150 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 TLE * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M, K;
    cin >> N >> M >> K;

    vector<int> C(N);
    for (int &x : C) cin >> x;

    vector<long long> A(M + 1);
    for (int i = 1; i <= M; i++) cin >> A[i];

    vector<int> freq(M + 1, 0);


    for (int i = 0; i < K; i++)
        freq[C[i]]++;

    long long ans = LLONG_MAX;

    for (int L = 0; L + K <= N; L++) {


        for (int j = 1; j <= M; j++) {
            long long cost = (long long)(K - freq[j]) * A[j];
            ans = min(ans, cost);
        }


        if (L + K < N) {
            freq[C[L]]--;
            freq[C[L + K]]++;
        }
    }

    cout << ans << "\n";

    return 0;
}
0