#include <bits/stdc++.h>
#define NAME "BWTREE"
#define ll long long
#define ii pair<ll, ll>
#define mo(i, a, b) for (int i = a; i <= b; i++)
#define me(i, a, b) for (int i = a; i >= b; i--)
#define bit(mask, i) ((mask >> i) & 1)
const ll N = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll base = 31;
const ll inf = 1e18;
using namespace std;
ii a[N];
ll c[N], n, m;
ll check(ll k){
ll j = m - k;
mo(i, 0, n - 1){
if(j == m) break;
if(a[i].second <= c[j]) j++;
}
return j == m;
}
int main()
{
///freopen(NAME".inp", "r", stdin);
///freopen(NAME".out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
mo(i, 0, n - 1) cin >> a[i].second >> a[i].first;
mo(i, 0, m - 1) cin >> c[i];
sort(a + 1, a + n);
sort(c + 1, c + m);
ll l = 0, r = min(n, m);
while(r - l > 1){
ll mid = l + r >> 1;
if(check(mid)) l = mid;
else r = mid - 1;
}
cout << l << "\n";
return 0;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:37:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
37 | ll mid = l + r >> 1;
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |