結果
| 問題 |
No.2422 regisys?
|
| コンテスト | |
| ユーザー |
m_99
|
| 提出日時 | 2023-08-12 13:53:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,119 bytes |
| コンパイル時間 | 4,652 ms |
| コンパイル使用メモリ | 238,012 KB |
| 実行使用メモリ | 57,116 KB |
| 最終ジャッジ日時 | 2024-11-19 16:33:13 |
| 合計ジャッジ時間 | 26,434 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 60 TLE * 1 |
ソースコード
#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;
}
m_99