結果

問題 No.2422 regisys?
ユーザー m_99m_99
提出日時 2023-08-12 15:25:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 1,042 bytes
コンパイル時間 4,717 ms
コンパイル使用メモリ 273,144 KB
実行使用メモリ 14,372 KB
最終ジャッジ日時 2024-04-30 09:14:10
合計ジャッジ時間 13,611 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 123 ms
6,940 KB
testcase_32 AC 167 ms
6,940 KB
testcase_33 AC 116 ms
7,168 KB
testcase_34 AC 70 ms
6,940 KB
testcase_35 AC 143 ms
8,264 KB
testcase_36 AC 120 ms
6,940 KB
testcase_37 AC 174 ms
6,940 KB
testcase_38 AC 125 ms
6,940 KB
testcase_39 AC 87 ms
6,940 KB
testcase_40 AC 72 ms
6,944 KB
testcase_41 AC 86 ms
6,940 KB
testcase_42 AC 249 ms
12,184 KB
testcase_43 AC 122 ms
6,940 KB
testcase_44 AC 269 ms
11,872 KB
testcase_45 AC 223 ms
10,724 KB
testcase_46 AC 267 ms
11,852 KB
testcase_47 AC 155 ms
6,944 KB
testcase_48 AC 286 ms
13,888 KB
testcase_49 AC 198 ms
8,000 KB
testcase_50 AC 259 ms
13,992 KB
testcase_51 AC 333 ms
11,236 KB
testcase_52 AC 121 ms
7,872 KB
testcase_53 AC 269 ms
11,692 KB
testcase_54 AC 374 ms
14,372 KB
testcase_55 AC 286 ms
12,936 KB
testcase_56 AC 243 ms
9,236 KB
testcase_57 AC 365 ms
10,616 KB
testcase_58 AC 367 ms
10,624 KB
testcase_59 AC 364 ms
10,748 KB
testcase_60 AC 365 ms
10,748 KB
testcase_61 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001



int main(){
	
	int n,m;
	cin>>n>>m;
	
	vector<pair<int,int>> a(n);//,b(n);
	rep(i,n)cin>>a[i].first;
	rep(i,n)cin>>a[i].second;
	
	sort(a.begin(),a.end());
	vector<vector<int>> t(2);
	rep(i,m){
		int x,y;
		cin>>x>>y;
		t[x].push_back(y);
	}
	rep(i,2)sort(t[i].begin(),t[i].end());
	
	int ans = 0;
	priority_queue<int> Q;
	int cp = 0;
	rep(i,t[0].size()){
		while(cp!=n && a[cp].first <= t[0][i]){
			Q.push(a[cp].second);
			cp++;
		}
		if(Q.size()>0){
			ans++;
			Q.pop();
		}
	}
	for(int i=cp;i<n;i++){
		Q.push(a[i].second);
	}
	
	multiset<int> b;
	while(Q.size()>0){
		b.insert(Q.top());
		Q.pop();
	}
	
	rep(i,t[1].size()){
		if(b.size()==0)break;
		auto it = b.upper_bound(t[1][i]);
		if(it==b.begin())continue;
		it--;
		ans++;
		b.erase(it);
	}
	cout<<n-ans<<endl;
	
	return 0;
}
0