#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << endl
#define all(x) x.begin(),x.end()
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n,m;cin>>n>>m;
pii a[n];
int b[m];
for(int i=0;i<n;i++) cin>>a[i].se>>a[i].fi;
for(int i=0;i<m;i++) cin>>b[i];
sort(a,a+n);
sort(b,b+m);
vector<int> v;
int x=lower_bound(b,b+m,a[0].se)-b,y;
int idx[n+1];
memset(idx,-1,sizeof(idx));
if(x!=m)
{
v.pb(a[0].se);
idx[0]=x;
}
for(int i=1;i<n;i++)
{
x=lower_bound(b,b+m,a[i].se)-b;
y=upper_bound(all(v),a[i].se)-v.begin();
if(v.size()==0)
{
if(x!=m)
{
v.pb(a[i].se);
idx[0]=x;
}
}
else if(y==v.size())
{
if(idx[v.size()-1]<m-1 && x!=m)
{
idx[v.size()]=max(idx[v.size()-1]+1,x);
v.pb(a[i].se);
}
}
else
{
v[y]=a[i].se;
idx[y]=x;
if(y-1>=0) idx[y]=max(idx[y],idx[y-1]+1);
}
}
cout<<v.size();
return 0;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:47:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | else if(y==v.size())
| ~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
436 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
436 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
436 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |