답안 #626123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626123 2022-08-11T08:44:14 Z l_reho Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define x first
#define y second

vector<pair<ll, ll>> P;
vector<ll> C;

int dp[1002][1002];

void solve(){
	int N, M;
	cin>>N>>M;
	
	P.assign(N, pair<ll, ll>());
	
	
	C.assign(M, 0);
	
	
	for(int i = 0; i < N; i++)
		cin>>P[i].x>>P[i].y;
		
	for(int j = 0; j < M; j++)
		cin>>C[j];
	
	sort(C.begin(), C.end());
	sort(P.begin(), P.end(), [&](pair<ll, ll> p1, pair<ll, ll> p2){
		return p1.second < p2.second;
	});
	
	int ans = 0;
	
	for(int i = 0; i <= M; i++){
		for(int j = 0; j <= N; j++){
			if(i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			
			if(P[j-1].first <= C[i-1]){
				dp[i][j] = dp[i-1][j-1]+1;
				ans = max(dp[i][j], ans);
				continue;
			}
			
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			
			ans = max(dp[i][j], ans);
		} 
	}
	
	cout<<ans<<endl;
	
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	solve();
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -