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>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007
using namespace std;
const int MAXN = 1001;
vector<int> frames;
vector<pair<int,int>> pics;
int n,m;
int dp[MAXN][MAXN];
int rec(int posP, int posF) {
if (posP >= n || posF >= m) return 0;
if (dp[posP][posF] != -1) return dp[posP][posF];
int ret = rec(posP+1,posF);
int org = posF;
for (; posF<m; posF++) {
if (frames[posF] >= pics[posP].second) {
ret = max(ret,rec(posP+1,posF+1)+1);
break;
}
}
return dp[posP][org] = ret;
}
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
MS(dp,-1);
cin>>n>>m;
pics.resize(n);
for (int i = 0; i<n; i++) cin>>pics[i].second>>pics[i].first;
sort(pics.begin(),pics.end());
frames.resize(m);
for (int i = 0; i<m; i++) cin>>frames[i];
sort(frames.begin(),frames.end());
cout<<rec(0,0)<<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... |