제출 #1334524

#제출 시각아이디문제언어결과실행 시간메모리
1334524crispxxExhibition (JOI19_ho_t2)C++20
0 / 100
1 ms356 KiB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

bool chmax(int &a, const int &b) {
	return a < b ? a = b, true : false;
}

void solve() {
	int n, m; cin >> n >> m;
	
	vector<array<int, 2>> a(n);
	
	for(int i = 0; i < n; i++) {
		cin >> a[i][1] >> a[i][0];
		a[i][1] = -a[i][1];
	}
	
	sort(a.begin(), a.end(), greater<>());
	
	vector<int> c(m);
	
	for(auto &x : c) cin >> x;
	
	sort(c.begin(), c.end(), greater<>());
	
	vector dp(m + 1, vector(n, 0));
	
	for(int i = 0; i < m; i++) {
		for(int j = 0; j < n; j++) {
			if(-a[j][1] > c[i]) continue;
			for(int k = 0; k < j; k++) {
				if(-a[j][1] <= -a[k][1]) {
					if( chmax(dp[i + 1][j], dp[i][k] + 1) ) {
						// cout << i + 1 << ' ' << j << " and " << i << ' ' << k << '\n';
						// cout << dp[i + 1][j] << " = " << dp[i][k] << " + " << 1 << '\n';
					}
				}
			}
			chmax(dp[i + 1][j], 1);
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i <= m; i++) {
		for(int j = 0; j < n; j++) {
			chmax(ans, dp[i][j]);
		}
	}
	
	cout << ans << '\n';
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...