結果

問題 No.2422 regisys?
ユーザー m_99m_99
提出日時 2023-08-12 13:53:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,119 bytes
コンパイル時間 4,212 ms
コンパイル使用メモリ 239,724 KB
実行使用メモリ 57,804 KB
最終ジャッジ日時 2024-04-30 04:24:40
合計ジャッジ時間 21,539 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 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 3 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 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 3 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 3 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 529 ms
18,760 KB
testcase_32 AC 302 ms
30,896 KB
testcase_33 AC 235 ms
16,988 KB
testcase_34 AC 115 ms
15,588 KB
testcase_35 AC 261 ms
19,584 KB
testcase_36 AC 206 ms
23,620 KB
testcase_37 AC 338 ms
31,304 KB
testcase_38 AC 196 ms
25,376 KB
testcase_39 AC 133 ms
18,564 KB
testcase_40 AC 185 ms
12,608 KB
testcase_41 AC 141 ms
17,864 KB
testcase_42 AC 435 ms
30,800 KB
testcase_43 AC 255 ms
22,624 KB
testcase_44 AC 752 ms
34,572 KB
testcase_45 AC 522 ms
29,148 KB
testcase_46 AC 878 ms
34,188 KB
testcase_47 AC 1,010 ms
24,796 KB
testcase_48 AC 381 ms
32,312 KB
testcase_49 AC 994 ms
31,224 KB
testcase_50 AC 269 ms
28,884 KB
testcase_51 AC 684 ms
48,284 KB
testcase_52 AC 193 ms
15,716 KB
testcase_53 TLE -
testcase_54 AC 456 ms
47,588 KB
testcase_55 AC 377 ms
33,224 KB
testcase_56 AC 298 ms
35,968 KB
testcase_57 AC 1,239 ms
57,316 KB
testcase_58 AC 1,225 ms
57,508 KB
testcase_59 AC 1,226 ms
57,804 KB
testcase_60 AC 1,204 ms
57,228 KB
testcase_61 AC 2 ms
6,940 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<int> a(n),b(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	
	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());
	
	mf_graph<int> G(m + n + 2);
	int S = m+n;
	int T = S+1;
	rep(i,n){
		G.add_edge(S,i,1);
		int d = distance(t[0].begin(),lower_bound(t[0].begin(),t[0].end(),a[i]));
		if(d!=t[0].size())G.add_edge(i,n+d,1);
		d = distance(t[1].begin(),lower_bound(t[1].begin(),t[1].end(),b[i]));
		if(d!=t[1].size())G.add_edge(i,n+t[0].size()+d,1);
	}
	rep(i,t[0].size()){
		G.add_edge(n+i,T,1);
		if(i!=t[0].size()-1)G.add_edge(n+i,n+i+1,Inf32);
	}
	rep(i,t[1].size()){
		G.add_edge(n+t[0].size()+i,T,1);
		if(i!=t[1].size()-1)G.add_edge(n+t[0].size()+i,n+i+t[0].size()+1,Inf32);
	}
	int ans = G.flow(S,T);
	ans = n-ans;
	cout<<ans<<endl;
	return 0;
}
0