結果

問題 No.2422 regisys?
ユーザー through
提出日時 2023-08-12 15:23:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,354 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 204,980 KB
最終ジャッジ日時 2025-02-16 06:18:22
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 60 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
#define rep(i, n) for(ll i = 0; i < n; i++)

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    ll n,m; cin >> n >> m;
    priority_queue<P,vector<P>,greater<P>> a, b, mem;
    rep(i,n) {
        ll aa; cin >> aa;
        a.push(P(aa,i));
    }
    rep(i,n) {
        ll bb; cin >> bb;
        b.push(P(bb,i));
    }
    rep(i,m) {
        ll t,c; cin >> t >> c;
        mem.push(P(c,1-t));
    }
    ll ans = 0;
    set<ll> bought;
    while( !mem.empty() ) {
        auto [money,t] = mem.top(); mem.pop();
        t = 1-t;
        if( t == 0 ) {
            while( !a.empty() && bought.count(a.top().second) ) a.pop();
            if( !a.empty() && a.top().first <= money ) {
                bought.insert(a.top().second);
                ans++;
                a.pop();
            }
        }
        else {
            while( !b.empty() && bought.count(b.top().second) ) b.pop();
            if( !b.empty() && b.top().first <= money ) {
                bought.insert(b.top().second);
                ans++;
                b.pop();
            }
        }
    }
    cout << n-ans << endl;
    
    return 0;
}
0