結果

問題 No.2422 regisys?
ユーザー dyktr_06dyktr_06
提出日時 2023-06-21 16:44:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 1,726 bytes
コンパイル時間 2,811 ms
コンパイル使用メモリ 216,316 KB
実行使用メモリ 13,064 KB
最終ジャッジ日時 2023-10-19 17:34:43
合計ジャッジ時間 7,966 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 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 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 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 51 ms
6,748 KB
testcase_32 AC 70 ms
6,996 KB
testcase_33 AC 48 ms
6,608 KB
testcase_34 AC 30 ms
4,908 KB
testcase_35 AC 58 ms
7,704 KB
testcase_36 AC 51 ms
6,032 KB
testcase_37 AC 73 ms
7,332 KB
testcase_38 AC 53 ms
5,836 KB
testcase_39 AC 37 ms
5,156 KB
testcase_40 AC 30 ms
5,552 KB
testcase_41 AC 37 ms
5,112 KB
testcase_42 AC 100 ms
11,348 KB
testcase_43 AC 51 ms
6,072 KB
testcase_44 AC 108 ms
11,632 KB
testcase_45 AC 90 ms
9,460 KB
testcase_46 AC 108 ms
11,600 KB
testcase_47 AC 66 ms
7,312 KB
testcase_48 AC 110 ms
12,116 KB
testcase_49 AC 85 ms
8,752 KB
testcase_50 AC 101 ms
11,740 KB
testcase_51 AC 132 ms
11,520 KB
testcase_52 AC 47 ms
7,136 KB
testcase_53 AC 107 ms
11,224 KB
testcase_54 AC 136 ms
13,064 KB
testcase_55 AC 104 ms
11,440 KB
testcase_56 AC 92 ms
9,224 KB
testcase_57 AC 156 ms
12,104 KB
testcase_58 AC 155 ms
12,104 KB
testcase_59 AC 157 ms
12,100 KB
testcase_60 AC 155 ms
12,104 KB
testcase_61 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    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];
    }
    vector<pair<int, int>> p(n);
    for(int i = 0; i < n; i++){
        p[i] = {a[i], b[i]};
    }
    vector<int> t(m), c(m);
    vector<int> zero, one;
    for(int i = 0; i < m; i++){
        cin >> t[i] >> c[i];
        if(t[i] == 0) zero.push_back(c[i]);
        else one.push_back(c[i]);
    }

    sort(zero.begin(), zero.end());
    sort(one.begin(), one.end());
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q0_min, q1_min;
    priority_queue<pair<int, int>> q1_max;
    for(int i = 0; i < n; i++){
        q0_min.push(p[i]);
    }

    for(int i = 0; i < (int) zero.size(); i++){
        while(q0_min.size()){
            auto [x, y] = q0_min.top();
            if(x <= zero[i]){
                q1_max.emplace(y, x);
                q0_min.pop();
            }else{
                break;
            }
        }
        if(!q1_max.empty()){
            q1_max.pop();
        }
    }

    while(q0_min.size()){
        auto [x, y] = q0_min.top();
        q1_min.emplace(y, x);
        q0_min.pop();
    }
    while(q1_max.size()){
        auto [y, x] = q1_max.top();
        q1_min.emplace(y, x);
        q1_max.pop();
    }

    for(int i = 0; i < (int) one.size(); i++){
        if(!q1_min.empty()){
            auto [y, x] = q1_min.top();
            if(y <= one[i]){
                q1_min.pop();
            }
        }
    }
    int ans = q1_min.size();
    cout << ans << endl;
}
0