/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 1e5 + 10;
struct picture
{
int s, v;
}p[maxn];
bool cmp(picture p1, picture p2)
{
if (p1.s < p2.s)
return true;
if (p1.s > p2.s)
return false;
return p1.v < p2.v;
}
int n, m, c[maxn], dp[maxn];
bool check(int x)
{
int to = 0;
for (int i = 1; i <= n; i ++)
{
int lf = 1, rf = to;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (dp[mf] <= p[i].v)
lf = mf + 1;
else
rf = mf - 1;
}
if (c[(m - x) + lf] < p[i].s)
continue;
dp[lf] = p[i].v;
if (lf > to)
to = lf;
}
return (to >= x);
}
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++)
{
cin >> p[i].s >> p[i].v;
}
for (int i = 1; i <= m; i ++)
cin >> c[i];
sort(c + 1, c + m + 1);
sort(p + 1, p + n + 1, cmp);
///cout << check(2) << endl;
///return;
int lf = 0, rf = m;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (check(mf))
lf = mf + 1;
else
rf = mf - 1;
}
cout << rf << endl;
}
int main()
{
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |