結果

問題 No.2422 regisys?
ユーザー InTheBloomInTheBloom
提出日時 2024-03-06 07:54:51
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,663 bytes
コンパイル時間 5,601 ms
コンパイル使用メモリ 186,480 KB
実行使用メモリ 17,188 KB
最終ジャッジ日時 2024-03-06 07:55:06
合計ジャッジ時間 13,976 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 WA -
testcase_02 AC 1 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,676 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,676 KB
testcase_13 WA -
testcase_14 AC 1 ms
6,676 KB
testcase_15 WA -
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
6,676 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 91 ms
8,380 KB
testcase_32 WA -
testcase_33 AC 77 ms
8,380 KB
testcase_34 WA -
testcase_35 AC 93 ms
8,224 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 154 ms
16,592 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 180 ms
15,548 KB
testcase_47 WA -
testcase_48 AC 184 ms
16,708 KB
testcase_49 WA -
testcase_50 AC 139 ms
17,188 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N, M; readln.read(N, M);
    auto A = readln.split.to!(int[]);
    auto B = readln.split.to!(int[]);

    int[] mma, non_mma;

    foreach (i; 0..M) {
        int T, C; readln.read(T, C);

        if (T == 0) non_mma ~= C;
        if (T == 1) mma ~= C;
    }

    solve(N, M, A, B, mma, non_mma);
}

void solve (int N, int M, int[] A, int[] B, int[] mma, int[] non_mma) {
    auto items = new Tuple!(int, int, int)[](N);
    foreach (i; 0..N) {
        items[i] = tuple(i, A[i], B[i]);
    }

    items.sort!"a[1] < b[1]";
    non_mma.sort;

    auto used = new bool[](N);

    {
        BinaryHeap!(Tuple!(int, int)[], "a[1] < b[1]") PQ = [];
        // rangeだけ使う
        auto r = items;

        foreach (v; non_mma) {
            while (!r.empty && r.front[1] <= v) {
                PQ.insert(tuple(r.front[0], r.front[2]));
                r.popFront;
            }

            if (PQ.empty) continue;
            used[PQ.front[0]] = true;
            PQ.removeFront;
        }
    }

    mma.sort;
    BinaryHeap!(Tuple!(int, int)[], "b[1] < a[1]") PQ = [];
    foreach (i; 0..N) {
        if (used[i]) continue;
        PQ.insert(tuple(items[i][0], items[i][2]));
    }

    foreach (v; mma) {
        if (PQ.empty) break;
        if (v < PQ.front[1]) continue;
        used[PQ.front[0]] = true;
        PQ.removeFront;
    }

    int ans = 0;
    foreach (i; 0..N) if (!used[i]) ans++;

    writeln(ans);
}

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