#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define pb push_back
#define ff first
#define ss second
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin>>n;
vector<int> a(n + 1), c(n + 1), f[n + 1];
for (int i = 1; i <= n; i++){
cin>>a[i]>>c[i];
f[a[i]].pb(c[i]);
}
for (int i = 1; i <= n; i++){
reverse(f[i].begin(), f[i].end());
}
vector<int> b(n + 1), d(n + 1);
for (int i = 1; i <= n; i++){
cin>>b[i]>>d[i];
}
vector<int> s(n + 1);
int out = n;
for (int i = n; i > 0; i--){
int x = b[i];
if (s[x] != f[x].size() && f[x][s[x]] <= d[i]){
out--;
s[x]++;
}
}
cout<<out<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |