#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
const int maxn = 100000;
int n, m;
pi a[maxn];
int b[maxn];
vector<int> v;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> a[i].s >> a[i].f;
for(int i = 0; i < m; i++) cin >> b[i];
sort(a, a + n, greater<pi>());
sort(b, b + m, greater<int>());
for(int i = 0; i < n; i++){
int it = upper_bound(v.begin(), v.end(), a[i].s, greater<int>()) - v.begin();
if(it >= m || a[i].s > b[it]) continue;
if(it < v.size()) v[it] = a[i].s;
else v.push_back(a[i].s);
}
cout << v.size() << endl;
return 0;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:33:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(it < v.size()) v[it] = a[i].s;
~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |