#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
const ll INF = 1e12;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
// int s[N];
// int v[N];
int c[N];
pair<int,int> a[N];
bool cmp(pll i,pll j){
if(i.s < j.s) return true;
if(i.s > j.s) return false;
return(i.f < j.f);
}
void solve(){
int n;
cin >> n;
int m;cin>>m;
for(int i=1;i<=n;i++){
cin >> a[i].f >> a[i].s;
}
sort(a+1,a+n+1,cmp);
for(int i =1;i<=m;i++) cin >> c[i];
sort(c+1,c+m+1);
int lo = 1;
int ans = 0;
for(int i=1;i<=n;i++){
int hi = m;
int idx = INF;
int tmp = lo;
while(lo <= hi){
int mid = (lo + hi) >> 1ll;
if(c[mid] >= a[i].f){
idx = min(idx,mid);
hi = mid-1;
}
else lo = mid+1;
}
if(idx == INF){
lo = tmp;
}
else{
ans++;
lo = idx+1;
}
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
// freopen(".in","r",stdin);freopen(".out","w",stdout);
ll tt=1;
// cin >> tt;
while(tt--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |