結果

問題 No.2422 regisys?
ユーザー t98slider
提出日時 2023-08-14 19:56:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 182,696 KB
実行使用メモリ 7,388 KB
最終ジャッジ日時 2024-11-22 20:08:44
合計ジャッジ時間 9,028 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> a(n);
    vector<int> b;
    for(int i = 0; i < n; i++) cin >> a[i].first;
    for(int i = 0; i < n; i++) cin >> a[i].second;
    for(int i = 0; i < m; i++){
        int t, v;
        cin >> t >> v;
        if(t == 0){
            a.emplace_back(v, 1 << 30);
        }else{
            b.emplace_back(v);
        }
    }
    priority_queue<int> pq;
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    int ans = 0;
    for(int i = 0; i < a.size(); i++){
        int u, v;
        tie(u, v) = a[i];
        if(v >> 30 & 1){
            if(!pq.empty()) pq.pop();
        }else{
            pq.emplace(v);
        }
    }
    for(int i = 0; i < b.size(); i++){
        while(!pq.empty() && pq.top() > b[i]){
            pq.pop();
            ans++;
        }
        if(!pq.empty()) pq.pop();
    }
    cout << ans + pq.size() << '\n';
}
0