#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second
const ll mxn = 1e5+10;
int main(){
ll n,m;
cin>>n>>m;
pll arr[n];
for(auto &i:arr)cin>>i.fs>>i.sc;
ll brr[m];
for(auto &i:arr)i.fs = -i.fs,i.sc = -i.sc;
for(auto &i:brr)cin>>i,i = -i;
sort(arr,arr+n);
sort(brr,brr+m);
vector<pll> b;
for(auto &i:brr){
if(b.empty()||b.back().fs != i)b.push_back({i,1});
else b.back().sc++;
}
vector<ll> lis;
ll len = 0;
ll p = 0;
b.push_back({0,0});
while(p<n&&arr[p].fs<b[0].fs)p++;
for(int i = 0;i<b.size()-1;i++){
auto tmp = b[i];
len += tmp.sc;
vector<int> v;
while(p<n&&arr[p].fs<b[i+1].fs){
v.push_back(arr[p].sc);
p++;
}
sort(v.begin(),v.end());
for(auto &j:v){
auto pos = upper_bound(lis.begin(),lis.end(),j)-lis.begin();
if(pos == lis.size())lis.push_back(j);
else lis[pos] = j;
}
while(lis.size()>len)lis.pop_back();
//cout<<lis.size()<<endl;
}
/*
for(auto &i:b)cout<<i.fs<<' '<<i.sc<<',';cout<<endl;
for(auto &i:arr)cout<<i.fs<<' '<<i.sc<<',';cout<<endl;
*/
cout<<lis.size();
return 0;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i = 0;i<b.size()-1;i++){
| ~^~~~~~~~~~~
joi2019_ho_t2.cpp:41:11: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if(pos == lis.size())lis.push_back(j);
| ~~~~^~~~~~~~~~~~~
joi2019_ho_t2.cpp:44:19: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
44 | while(lis.size()>len)lis.pop_back();
| ~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
0 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 |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |