結果

問題 No.2549 Paint Eggs
ユーザー InTheBloomInTheBloom
提出日時 2023-11-20 19:51:53
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,194 bytes
コンパイル時間 1,668 ms
コンパイル使用メモリ 165,856 KB
実行使用メモリ 28,456 KB
最終ジャッジ日時 2023-11-20 19:52:01
合計ジャッジ時間 7,294 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,676 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 89 ms
25,960 KB
testcase_11 AC 69 ms
15,240 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 48 ms
14,292 KB
testcase_15 AC 6 ms
6,676 KB
testcase_16 AC 77 ms
15,660 KB
testcase_17 AC 51 ms
10,864 KB
testcase_18 AC 41 ms
10,648 KB
testcase_19 AC 61 ms
11,512 KB
testcase_20 WA -
testcase_21 AC 110 ms
28,324 KB
testcase_22 AC 111 ms
28,348 KB
testcase_23 AC 112 ms
28,284 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 103 ms
28,192 KB
testcase_27 AC 106 ms
28,332 KB
testcase_28 AC 113 ms
28,224 KB
testcase_29 AC 109 ms
28,252 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 108 ms
28,456 KB
testcase_33 AC 105 ms
28,380 KB
testcase_34 AC 105 ms
28,208 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 110 ms
28,384 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 113 ms
28,368 KB
testcase_41 AC 114 ms
28,316 KB
testcase_42 AC 114 ms
28,260 KB
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N, M, K; readln.read(N, M, K);
    int[] C = readln.split.to!(int[]);
    C[] -= 1;
    int[] A = readln.split.to!(int[]);

    solve(N, M, K, C, A);
}

void solve (int N, int M, int K, int[] C, int[] A) {
    /* スライドしていけば良さそう */
    int[int] mp;
    // 最初の一回
    foreach (i; 0..K) mp[C[i]]++;

    long ans = long.max;

    foreach (key, val; mp) {
        ans = min(ans, 1L*(K-val)*A[key]);
    }

    int left = 0, right = K;
    while (right < N) {
        // [left, right)を保持している
        // leftを除去してrightを加入させる

        mp[C[left]]--;
        mp[C[right]]++;
        ans = min(ans, 1L*(K-mp[C[left]])*A[C[left]]);
        ans = min(ans, 1L*(K-mp[C[right]])*A[C[right]]);

        left++, right++;

        //dbg
        //writeln("[", left, ", ", right, ") ", mp);
    }

    // ハマった。単に全部塗り替えるのが最適な場合がある
    foreach (c; C) {
        ans = min(ans, 1L*K*A[c]);
    }

    writeln(ans);
}

void read(T...)(string S, ref T args) {
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}
0