이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |