結果

問題 No.2422 regisys?
ユーザー RhoRho
提出日時 2023-08-12 15:00:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,064 bytes
コンパイル時間 4,308 ms
コンパイル使用メモリ 245,272 KB
実行使用メモリ 48,740 KB
最終ジャッジ日時 2024-04-30 07:48:27
合計ジャッジ時間 22,557 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,944 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,940 KB
testcase_15 WA -
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 235 ms
15,352 KB
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 AC 648 ms
31,624 KB
testcase_49 WA -
testcase_50 AC 552 ms
29,872 KB
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.first,1);
        }
    }
    sort(all(t0));
    for(int e:t0){
        int ss=fw.sum(0,e+1);
        if(ss==0)continue;
        else{
            int lb=-1,ub=e;
            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);
        }
    }
    cout<<fw.sum(0,event.size())<<endl;

}
0