結果

問題 No.2422 regisys?
ユーザー ryota2357ryota2357
提出日時 2023-07-19 14:45:50
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 1,526 bytes
コンパイル時間 2,390 ms
コンパイル使用メモリ 122,900 KB
実行使用メモリ 8,552 KB
最終ジャッジ日時 2023-10-19 17:34:32
合計ジャッジ時間 12,643 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 104 ms
5,088 KB
testcase_32 AC 157 ms
5,056 KB
testcase_33 AC 97 ms
5,248 KB
testcase_34 AC 67 ms
4,348 KB
testcase_35 AC 119 ms
5,912 KB
testcase_36 AC 114 ms
4,628 KB
testcase_37 AC 163 ms
5,372 KB
testcase_38 AC 120 ms
4,448 KB
testcase_39 AC 83 ms
4,348 KB
testcase_40 AC 62 ms
4,500 KB
testcase_41 AC 81 ms
4,348 KB
testcase_42 AC 205 ms
7,936 KB
testcase_43 AC 113 ms
4,788 KB
testcase_44 AC 225 ms
8,012 KB
testcase_45 AC 184 ms
6,968 KB
testcase_46 AC 219 ms
7,996 KB
testcase_47 AC 137 ms
5,488 KB
testcase_48 AC 225 ms
8,520 KB
testcase_49 AC 177 ms
6,296 KB
testcase_50 AC 205 ms
8,356 KB
testcase_51 AC 292 ms
7,612 KB
testcase_52 AC 100 ms
5,524 KB
testcase_53 AC 224 ms
7,696 KB
testcase_54 AC 307 ms
8,552 KB
testcase_55 AC 238 ms
8,048 KB
testcase_56 AC 208 ms
6,240 KB
testcase_57 AC 330 ms
8,152 KB
testcase_58 AC 330 ms
8,156 KB
testcase_59 AC 331 ms
7,888 KB
testcase_60 AC 332 ms
8,152 KB
testcase_61 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab(n);
    for (int i = 0; i < n; ++i) cin >> ab[i].first;
    for (int i = 0; i < n; ++i) cin >> ab[i].second;
    vector<int> t0, t1;
    for (int i = 0; i < m; ++i) {
        int t, c;
        cin >> t >> c;
        if (t == 0) {
            t0.push_back(c);
        } else {
            t1.push_back(c);
        }
    }

    sort(t0.begin(), t0.end());
    sort(t1.begin(), t1.end());
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> small;
    priority_queue<int> large;
    for (int i = 0; i < n; ++i) {
        small.emplace(ab[i]);
    }
    for (const auto x : t0) {
        while (small.size() && small.top().first <= x) {
            auto [a, b] = small.top();
            small.pop();
            large.emplace(b);
        }
        if (large.empty()) {
            continue;
        }
        large.pop();
    }
    vector<int> min_v;
    while (small.size()) {
        auto [a, b] = small.top();
        small.pop();
        min_v.push_back(b);
    }
    while (large.size()) {
        min_v.push_back(large.top());
        large.pop();
    }
    sort(min_v.rbegin(), min_v.rend());
    for (const auto x : t1) {
        if (min_v.empty()) {
            break;
        }
        if (min_v.back() <= x) {
            min_v.pop_back();
        }
    }
    cout << min_v.size() << endl;
    return 0;
}
0