結果

問題 No.2422 regisys?
ユーザー ryota2357ryota2357
提出日時 2023-07-19 14:54:35
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,525 bytes
コンパイル時間 1,098 ms
コンパイル使用メモリ 122,944 KB
実行使用メモリ 8,528 KB
最終ジャッジ日時 2023-10-19 17:34:54
合計ジャッジ時間 9,320 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 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 1 ms
4,348 KB
testcase_19 AC 1 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 2 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 105 ms
5,064 KB
testcase_32 AC 154 ms
5,032 KB
testcase_33 AC 97 ms
5,224 KB
testcase_34 AC 67 ms
4,348 KB
testcase_35 AC 118 ms
5,888 KB
testcase_36 AC 112 ms
4,604 KB
testcase_37 AC 162 ms
5,348 KB
testcase_38 AC 119 ms
4,424 KB
testcase_39 AC 82 ms
4,348 KB
testcase_40 AC 63 ms
4,476 KB
testcase_41 AC 81 ms
4,348 KB
testcase_42 AC 204 ms
7,912 KB
testcase_43 AC 112 ms
4,764 KB
testcase_44 AC 222 ms
7,988 KB
testcase_45 AC 184 ms
6,944 KB
testcase_46 AC 218 ms
7,972 KB
testcase_47 AC 137 ms
5,464 KB
testcase_48 AC 223 ms
8,496 KB
testcase_49 AC 177 ms
6,272 KB
testcase_50 AC 204 ms
8,332 KB
testcase_51 AC 290 ms
7,588 KB
testcase_52 AC 98 ms
5,500 KB
testcase_53 AC 222 ms
7,672 KB
testcase_54 AC 303 ms
8,528 KB
testcase_55 AC 234 ms
8,024 KB
testcase_56 AC 207 ms
6,216 KB
testcase_57 AC 328 ms
8,128 KB
testcase_58 AC 327 ms
8,132 KB
testcase_59 AC 328 ms
7,864 KB
testcase_60 AC 328 ms
8,128 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

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