#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a, I = b; i <= I; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int N = 100005;
pii a[N];
int c[N];
signed main() {
IO;
int n, m;
cin >> n >> m;
FOR(i, 0, n - 1) cin >> a[i].first >> a[i].second;
FOR(i, 0, m - 1) cin >> c[i];
sort(a, a + n, greater<pii>());
sort(c, c + m, greater<int>());
vector<int> tmp;
int id = 0;
FOR(i, 0, n - 1) {
int l = -1, r = tmp.size();
while (l + 1 < r) {
int mid = (l + r) >> 1;
if (a[i].second > tmp[mid])
r = mid;
else
l = mid;
}
if (r == tmp.size()) {
if (r < m && a[i].first <= c[r])
tmp.push_back(a[i].second);
} else {
if (r < m && a[i].first <= c[r])
tmp[r] = a[i].second;
}
}
cout << tmp.size() << "\n";
return 0;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:36:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | if (r == tmp.size()) {
| ~~^~~~~~~~~~~~~
joi2019_ho_t2.cpp:26:9: warning: unused variable 'id' [-Wunused-variable]
26 | int id = 0;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |