# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
227364 | bharat2002 | Exhibition (JOI19_ho_t2) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N=1e5 + 100;
#define int long long
#define pii pair<int, int>
#define f first
#define s second
//Trace prints the name of the variable and the value.
int n, m, arr[N];
struct comp
{
bool operator()(pii a, pii b)
{
if(a.f==b.f) return a.s<=b.s;return a.f<b.f;
}
};
priority_queue< pii, vector< pii>, comp > pq;
bool sf(int a, int b)
{
return a>b;
}
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
int ss, v;cin>>ss>>v;pq.push(mp(v, ss));
}
for(int i=1;i<=m;i++) cin>>arr[i];
sort(arr+1, arr+m+1, sf);;
int ans=0;
for(int i=1;i<=m;i++)
{
while(!pq.empty()&&pq.top().s>arr[i]) pq.pop();
if(pq.empty()) break;
ans++;pq.pop();
}
cout<<ans;
}