結果

問題 No.2422 regisys?
ユーザー t98slider
提出日時 2023-08-12 15:28:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,213 bytes
コンパイル時間 2,356 ms
コンパイル使用メモリ 185,404 KB
実行使用メモリ 13,168 KB
最終ジャッジ日時 2024-11-20 02:31:07
合計ジャッジ時間 8,668 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 45 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int solve(vector<pair<int,int>> a, vector<int> a1, vector<int> b){
    int n = a.size();
    int ans = 0;
    sort(a.rbegin(), a.rend());
    set<int> S;
    S.insert(1 << 30);
    priority_queue<int> pq;
    for(int i = 0; i < a1.size(); i++) pq.emplace(a1[i]);
    for(auto &&v : b) S.insert(v);
    for(int i = 0; i < n; i++){
        int v, v2;
        tie(v, v2) = a[i];
        if(!pq.empty() && pq.top() >= v){
            pq.pop();
            continue;
        }
        auto it = S.lower_bound(v2);
        if(*it == (1 << 30)) ans++;
        else S.erase(it);
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, t, v;
    cin >> n >> m;
    vector<pair<int,int>> a(n);
    vector<int> a1, a2;
    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++){
        cin >> t >> v;
        if(t == 0) a1.emplace_back(v);
        else a2.emplace_back(v);
    }
    int ans = solve(a, a1, a2);
    for(int i = 0; i < n; i++) swap(a[i].first, a[i].second);
    ans = min(ans, solve(a, a2, a1));
    cout << ans << '\n';
}
0