답안 #572059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572059 2022-06-03T12:38:15 Z 1ne Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
const long long mxn = 1e12;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long n,m;cin>>n>>m;
	vector<pair<long long ,long long>>arr(n);
	for (int i = 0;i<n;++i){
		cin>>arr[i].first>>arr[i].second;
	}
	vector<long long >brr(m);
	for (int i = 0;i<m;++i)cin>>brr[i];
	sort(brr.begin(),brr.end());
	sort(arr.begin(),arr.end(),[&](auto x,auto y){
		return x.second < y.second;
	});
	vector<vector<long long>>dp(n + 1,vector<long long>(m + 1,-1));
	function<long long(int,int)> solve = [&](int cur,int pos){
		if (cur==n)return 0LL;
		if (pos==m)return 0LL;
		if (dp[cur][pos]!=-1)return dp[cur][pos];
		long long ans = solve(cur + 1,pos);
		if (pos + 1 < m)
			ans = max(ans,solve(cur,pos + 1));
		if (pos < m && brr[pos]>=arr[cur].first){
			ans = max(ans,solve(cur + 1,pos + 1) + 1);
		}
		return dp[cur][pos] = ans;
	};
	long long ans = solve(0,0);
	cout<<ans<<'\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -