#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 b[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i].f >> a[i].s;
}
for(int i= 1; i <= m; i++) cin >> b[i];
int l = 0, r = n + 1;
sort(a + 1 , a + 1 + n);
sort(b + 1, b + 1 + m);
while(l + 1 < r){
int mid = (l + r) / 2;
multiset <ll> st;
ll last = -1;
bool ind = true;
int cur = 1;
for(int i = m - mid + 1; i <= m; i++){
while(cur <= n && a[cur].f <= b[i]) st.insert(a[cur].s), cur++;
multiset <ll> :: iterator it = st.lower_bound(last);
if(it == st.end()){
ind = false;
break;
}
last = *it;
st.erase(it);
}
if(ind) l = mid;
else r = mid;
}
cout << l;
}
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |