結果

問題 No.2422 regisys?
ユーザー Nzt3Nzt3
提出日時 2023-08-15 01:13:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 1,341 bytes
コンパイル時間 2,793 ms
コンパイル使用メモリ 219,996 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-05-02 13:41:10
合計ジャッジ時間 10,614 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 51 ms
5,376 KB
testcase_32 AC 70 ms
5,376 KB
testcase_33 AC 47 ms
5,376 KB
testcase_34 AC 30 ms
5,376 KB
testcase_35 AC 58 ms
5,964 KB
testcase_36 AC 51 ms
5,376 KB
testcase_37 AC 73 ms
5,376 KB
testcase_38 AC 53 ms
5,376 KB
testcase_39 AC 37 ms
5,376 KB
testcase_40 AC 31 ms
5,376 KB
testcase_41 AC 37 ms
5,376 KB
testcase_42 AC 98 ms
7,152 KB
testcase_43 AC 52 ms
5,376 KB
testcase_44 AC 108 ms
7,256 KB
testcase_45 AC 88 ms
6,928 KB
testcase_46 AC 107 ms
7,360 KB
testcase_47 AC 67 ms
5,376 KB
testcase_48 AC 108 ms
8,576 KB
testcase_49 AC 87 ms
5,632 KB
testcase_50 AC 96 ms
8,304 KB
testcase_51 AC 132 ms
6,868 KB
testcase_52 AC 46 ms
5,376 KB
testcase_53 AC 106 ms
6,528 KB
testcase_54 AC 136 ms
7,260 KB
testcase_55 AC 104 ms
6,656 KB
testcase_56 AC 92 ms
5,712 KB
testcase_57 AC 156 ms
7,384 KB
testcase_58 AC 156 ms
7,276 KB
testcase_59 AC 157 ms
7,400 KB
testcase_60 AC 157 ms
7,256 KB
testcase_61 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin>>N>>M;
  vector<array<int,3>>A(N);
  for(auto &i:A)cin>>i[0];
  for(auto &i:A)cin>>i[1];
  for(int i=0;i<N;i++)A[i][2]=i;
  sort(A.begin(),A.end());
  vector<int>p_A,p_B;
  for(int i=0;i<M;i++){
    int T,C;
    cin>>T>>C;
    if(T==1){
      p_B.push_back(C);
    }else{
      p_A.push_back(C);
    }
  }
  cerr<<"inout ok"<<endl;
  sort(p_A.begin(),p_A.end());
  sort(p_B.begin(),p_B.end());
  priority_queue<array<int,2>>pq1;
  vector<int>ans(N,1);
  for(int i=0,cnt=0;i<p_A.size();i++){
    while(cnt<N&&A[cnt][0]<=p_A[i]){
      pq1.push({A[cnt][1],A[cnt][2]});
      cnt+=1;
    }
    if(pq1.size()){
      int t=pq1.top()[1];
      pq1.pop();
      ans[t]=0;
    }
  }
  cerr<<"buy A ok"<<endl;
  sort(A.begin(),A.end(),[](array<int,3> a,array<int,3> b){
    return a[1]<b[1];
  });
  priority_queue<array<int,2>>pq2;
  for(int i=0,cnt=0;i<p_B.size();i++){
    while(cnt<N&&A[cnt][1]<=p_B[i]){
      pq2.push({A[cnt][1],A[cnt][2]});
      cnt+=1;
    }
    while(pq2.size()&&ans[pq2.top()[1]]==0){
      pq2.pop();
    }
    if(pq2.size()){
      int t=pq2.top()[1];
      pq2.pop();
      ans[t]=0;
    }
  }
  cerr<<"buy B ok"<<endl;
  cout<<accumulate(ans.begin(),ans.end(),0)<<'\n';
}
0