結果

問題 No.2422 regisys?
ユーザー InTheBloomInTheBloom
提出日時 2024-03-06 05:36:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,063 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 124,348 KB
実行使用メモリ 21,684 KB
最終ジャッジ日時 2024-03-06 05:36:35
合計ジャッジ時間 15,163 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 2 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 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,676 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 3 ms
6,676 KB
testcase_24 WA -
testcase_25 AC 2 ms
6,676 KB
testcase_26 WA -
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 125 ms
9,088 KB
testcase_32 AC 238 ms
12,536 KB
testcase_33 AC 111 ms
8,448 KB
testcase_34 AC 103 ms
7,900 KB
testcase_35 AC 135 ms
8,616 KB
testcase_36 AC 173 ms
10,776 KB
testcase_37 AC 271 ms
13,788 KB
testcase_38 AC 195 ms
11,356 KB
testcase_39 AC 123 ms
9,084 KB
testcase_40 WA -
testcase_41 AC 119 ms
8,320 KB
testcase_42 AC 226 ms
13,656 KB
testcase_43 AC 183 ms
9,500 KB
testcase_44 WA -
testcase_45 AC 211 ms
13,556 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 269 ms
13,424 KB
testcase_49 WA -
testcase_50 AC 211 ms
12,424 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 453 ms
20,308 KB
testcase_55 AC 288 ms
15,804 KB
testcase_56 AC 324 ms
15,496 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main () {
    int N, M; cin >> N >> M;
    vector<int> A(N), B(N);

    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    map<int, int> mma, non_mma;

    for (int i = 0; i < M; i++) {
        int T, C; cin >> T >> C;

        if (T == 0) {
            non_mma[C]++;
        }

        if (T == 1) {
            mma[C]++;
        }
    }

    enum TYPE {
        MMA,
        NON_MMA,
    };

    vector<bool> is_sold(N, false);
    vector<tuple<int, TYPE, int>> items; // (idx, type, cost)

    for (int i = 0; i < N; i++) {
        items.push_back(make_tuple(i, MMA, B[i]));
        items.push_back(make_tuple(i, NON_MMA, A[i]));
    }

    sort(items.begin(), items.end(), [](tuple<int, int, int> a, tuple<int, int, int> b) { return get<2>(a) > get<2>(b); });

    for (auto& v : items) {
        int idx = get<0>(v);
        TYPE type = get<1>(v);
        int cost = get<2>(v);

        // もう売れている
        if (is_sold[idx]) continue;

        // 誰も買えない
        if (mma.lower_bound(cost) == mma.end()
                && non_mma.lower_bound(cost) == non_mma.end()) continue;

        auto nit = non_mma.lower_bound(cost);
        auto it = mma.lower_bound(cost);

        if (type == MMA) {
            if (nit == non_mma.end()) {
                (it->second)--;
                if (it->second == 0) mma.erase(it);
            }
            else {
                (nit->second)--;
                if (nit->second == 0) non_mma.erase(nit);
            }
        }

        if (type == NON_MMA) {
            if (it == mma.end()) {
                (nit->second)--;
                if (nit->second == 0) non_mma.erase(nit);
            }
            else {
                (it->second)--;
                if (it->second == 0) mma.erase(it);
            }
        }

        is_sold[idx] = true;
    }

    int ans = 0;
    for (const auto& v : is_sold) if (!v) ans++;

    cout << ans << "\n";
}
0