Submission #883015

#TimeUsernameProblemLanguageResultExecution timeMemory
883015vjudge1Exhibition (JOI19_ho_t2)C++17
50 / 100
276 ms8624 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,mmx,bmi,bmi2,popcnt,lzcnt,sse4.2,abm")
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e3;
int n, m, dp[MAXN+5][MAXN+5], f[MAXN+5];
pair<int, int> p[MAXN];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int i=0; i<n; i++) cin>>p[i].second>>p[i].first;
	for(int i=0; i<m; i++) cin>>f[i];
	sort(f, f+m, greater<int>());
	sort(p, p+n, greater<pair<int,int>>());
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			if(p[i-1].second <= f[j-1]) dp[i][j] = max(dp[i-1][j-1]+1, max(dp[i-1][j], dp[i][j-1]));
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	cout << dp[n][m] << '\n';
	/* for(int i=0; i<=n; i++) { */
	/* 	for(int j=0; j<=m; j++) cout<<dp[i][j] << ' '; */
	/* 	cout<<endl; */
	/* } */
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...