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;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const int inf = 2e9;
void print(vector<int> a, int n) {
for (int i=0; i<n; i++) {
cout<<a[i]<<" ";
}
cout<<endl;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, m;
cin>>n>>m;
vector<pair<int,int>> a(n); // (val, size)
for (int i=0; i<n; i++) {
cin>>a[i].second>>a[i].first;
}
sort(a.begin(), a.end());
vector<int> w(m);
for (int i=0; i<m; i++) {
cin>>w[i];
}
sort(w.begin(),w.end());
vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
int size = a[i-1].second;
int frame = w[j-1];
dp[i][j] = max({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]+(size<=frame)});
}
}
cout<<dp[n][m]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |