/* Quick Note :
* Jangan Mikir Lama - lama, sampahin dulu aja kalo OI
* Always Try to reset
*/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 1e5 + 5;
ll n, m;
pair<ll,ll> a[nax];
ll frame[nax];
bool cmp(pair<ll,ll> xx, pair<ll,ll> yy){
return xx.ss < yy.ss;
}
ll cek(ll val){
ll idx = m - val + 1;
for(ll i = 1; i <= n; i++){
if(idx > m){
break;
}
else{
if(a[i].ff <= frame[idx]){
idx++;
}
}
}
return idx > m;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
cin >> n >> m;
for(ll i = 1; i <= n; i++){
cin >> a[i].ff >> a[i].ss;
}
for(ll i = 1; i <= m; i++) cin >> frame[i];
sort(frame + 1, frame + 1 + m);
sort(a + 1, a + 1 + n, cmp);
ll l = 0, r = m, ret = 0;
while(l <= r){
ll mid = (l + r) / 2;
if(cek(mid)){
ret = mid;
l = mid + 1;
}
else r = mid - 1;
}
cout << ret << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |