結果

問題 No.2422 regisys?
ユーザー RhoRho
提出日時 2023-08-12 15:13:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,036 bytes
コンパイル時間 4,578 ms
コンパイル使用メモリ 245,332 KB
実行使用メモリ 47,648 KB
最終ジャッジ日時 2024-04-30 08:25:56
合計ジャッジ時間 24,706 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,940 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
6,944 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P>PP;
typedef vector<ll> vi;
constexpr ll inf=1ll<<61;
constexpr ll mod=998244353;
typedef modint998244353 mi;
int a[200005],b[200005],t[200005],c[200005];
int main(){
    int n,m;cin>>n>>m;
    vector<int>event;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n){
        event.push_back(a[i]);
        event.push_back(b[i]);
    }
    rep(i,m){
        cin>>t[i]>>c[i];
        event.push_back(c[i]);
    }
    map<int,int>M;
    sort(all(event));
    event.erase(unique(all(event)),event.end());
    rep(i,event.size()){
        M[event[i]]=i;
    }
    vector<P>V;
    rep(i,n){
        a[i]=M[a[i]];
        b[i]=M[b[i]];
        V.push_back(P(b[i],a[i]));
    }
    
    vector<int>t0;
    rep(i,m){
        c[i]=M[c[i]];
        if(t[i]==0)t0.push_back(c[i]);
        else {
            V.push_back(P(c[i],inf));
        }
    }
    sort(all(V));
    fenwick_tree<int>fw(event.size());
    for(auto e:V){
        if(e.second==inf){
            if(fw.sum(0,e.first+1)==0)continue;
            else{
                int ss=fw.sum(0,e.first+1);
                int lb=-1,ub=e.first;
                while(ub-lb>1){
                    int mi=(ub+lb)/2;
                    if(fw.sum(0,mi+1)==ss){
                        ub=mi;
                    }
                    else lb=mi;
                }
                fw.add(ub,-1);
            }
        }
        else{
            fw.add(e.second,1);
        }
    }
    vector<int>V2;
    rep(i,event.size()){
        while(fw.sum(i,i+1)){
            V2.push_back(i);
            fw.add(i,-1);
        }
    }
    sort(all(t0));
    int ans=V2.size();
    int L=0;
    rep(i,V2.size()){
        while(L<t0.size()){
            if(V2[i]>t0[L])L++;
            else{
                ans--;break;
            }
        }
    }
    cout<<ans<<endl;

}
0