#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define epb emplace_back
using namespace std;
const ll linf = 1e18 + 1;
int main(){
int n; cin >> n;
int m; cin >> m;
vector <ll> d(n + 1, linf);
d[0] = 0;
pll a[n + 1];
ll c[m + 1];
for(int i = 1; i <= n; i++) cin >> a[i].f >> a[i].s;
for(int i = 1; i <= m; i++) cin >> c[i];
sort(a + 1, a + 1 + n);
sort(c + 1, c + m + 1);
int ind = 1;
ll ans = 0;
ll res = 0;
for(int i = 1; i <= m; i++){
while(a[ind].f <= c[i]){
ll x = upper_bound(d.begin(), d.end(), a[ind].s) - d.begin();
res = max(res, x);
d[x] = a[ind].s;
ind++;
}
ans = min(res, (ll)i);
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
- |