이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
typedef long long llong;
const int MAXN = 100000 + 10;
int n, m;
int c[MAXN];
std::pair < int, int > p[MAXN];
bool check(int count)
{
int from = m - count + 1;
for (int i = 1 ; i <= n && from <= m ; ++i)
{
if (p[i].first <= c[from])
{
++from;
}
}
return from == m+1;
}
void solve()
{
std::sort(c+1, c+1+m);
std::sort(p+1, p+1+n, [&](std::pair < int, int > a, std::pair < int, int > b)
{
return std::make_pair(a.second, a.first) < std::make_pair(b.second, b.first);
});
int l = 0, r = n+1, mid;
while (l < r - 1)
{
mid = (l + r) / 2;
if (check(mid)) l = mid;
else r = mid;
}
std::cout << l << '\n';
}
void read()
{
std::cin >> n >> m;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> p[i].first >> p[i].second;
}
for (int i = 1 ; i <= m ; ++i)
{
std::cin >> c[i];
}
}
void fastIO()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main ()
{
fastIO();
read();
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |