#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], p[maxn];
vector<pi> v;
bool works(int x){
for(int i = v[x].s, j = m - 1; ~i; i = p[i], j--){
if(b[j] < a[i].s) return 0;
}
return 1;
}
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);
sort(b, b + m);
for(int i = 0; i < n; i++){
int it = lower_bound(v.begin(), v.end(), (pi){a[i].s, n}) - v.begin();
if(it < v.size()) v[it] = {a[i].s, i};
else v.push_back({a[i].s, i});
p[i] = it ? v[it - 1].s : -1;
}
int l = -1, r = min(m, (int)v.size());
while(r - l > 1){
int mid = (l + r) / 2;
if(works(mid)) l = mid;
else r = mid;
}
cout << (l + 1) << endl;
return 0;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:39:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(it < v.size()) v[it] = {a[i].s, i};
~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |