#include <bits/stdc++.h>
#include <ctime>
#include <algorithm>
#include <random>
using namespace std;
#define el '\n'
#define ll long long
#define fi first
#define se second
#define BIT(mask, i) (((mask) >> (i)) & 1)
#define MASK(i) (1LL << (i))
const ll INF = (ll)1e18 + 9;
const int oo = (int)1e9 + 7;
const ll MOD = (ll)1e9 + 7;
template <class T1, class T2>
bool minimize(T1 &a, T2 b) {
if(a > b) {a = b; return true;} return false;
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b) {
if(a < b) {a = b; return true;} return false;
}
template <class T1, class T2>
void add (T1 &a, T2 b) {
a += b;
if (a >= MOD) a -= MOD;
}
const int N = 100100;
int n, m;
pair <ll, ll> pics [N];
ll frames[N];
void init (void) {
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> pics[i].fi >> pics[i].se;
for (int i = 1; i <= m; i++) cin >> frames[i];
}
int f[N];
bool cmp (pair <ll, ll> a, pair <ll, ll> b) {
if(a.se != b.se) return a.se < b.se;
else return a.fi < b.fi;
}
void solve (void) {
sort (pics + 1, pics + n + 1, cmp);
int ans = 0;
sort(frames + 1, frames + m + 1);
int j = n;
for (int i = m; i >= 1; i--) {
while(frames[i] < pics[j].fi && i > 0) i--;
if(frames[i] >= pics[j].fi) {
ans++;
}
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test "test"
// freopen (test".inp", "r", stdin);
// freopen (test".out", "w", stdout);
srand(time(0));
int ntest = 1;
// cin >> ntest;
while(ntest--) {
init();
solve();
}
return 0;
}
// chim chim chim orz orz orz
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |