This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
const int maxn = 1e5+10;
const int mod = 1e9+7;
int n, m;
vector<pair<int,int>> v;
int s[maxn];
bool ok(int k)
{
if(k > n || k > m) return 0;
vector<pair<int,int>> ve;
for(int i = 0; i < k; i++)
ve.push_back({v[i].S,v[i].F});
sort(ve.begin(),ve.end());
vector<int> v1;
for(int i = m-k; i < m; i++)
v1.push_back(s[i]);
for(int i = 0; i < k; i++)
if(ve[i].S > v1[i])
return 0;
return 1;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>> n >> m;
for(int i = 0; i < n; i++){
int a, b; cin>> a >> b;
v.push_back({a,b});
}
sort(v.begin(),v.end());
for(int i = 0; i < m; i++) cin>> s[i];
sort(s,s+m);
int hi = n+1, lo = 0;
while(hi-lo > 1)
{
int tm = (hi+lo)/2;
if(ok(tm)) lo = tm;
else hi = tm;
}
cout<< lo;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |