This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maks = 1e5 + 5;
int dp[2][maks];
int n, m, bingkai[maks];
pair<int, int> gambar[maks];
bool com(pair<int, int> a, pair<int, int> b) {
return ((a.first < b.first) or (a.first == b.first and a.second < b.second));
}
signed main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> gambar[i].second >> gambar[i].first;
}
for (int i = 1; i <= m; i++) {
cin >> bingkai[i];
}
sort(bingkai+1, bingkai+1+m);
sort(gambar+1, gambar+1+n, com);
// for (int i = 1; i <= n; i++) cout << gambar[i].first << " " << gambar[i].second << endl;
// cout << endl;
// for (int i = 1; i <= m; i++) cout << bingkai[i] << endl;
// cout << endl;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (gambar[i].second <= bingkai[j]) dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][j-1]+1);
dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][j]);
dp[i%2][j] = max(dp[i%2][j], dp[i%2][j-1]);
}
}
cout << dp[n%2][m] << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |