Submission #110372

# Submission time Handle Problem Language Result Execution time Memory
110372 2019-05-10T18:27:52 Z pamaj Exhibition (JOI19_ho_t2) C++14
0 / 100
231 ms 275456 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e4;

int N, M;
int m[maxn];
int dp[maxn][maxn];

struct pic
{
	int val, sz;

	bool operator<(const pic& a) const
	{
		if(val == a.val) return sz < a.sz;
		return val < a.val;
	}

}v[maxn];


int solve(int i, int j)
{
	if(i == N or j == M) return 0;

	if(dp[i][j] != -1) return dp[i][j];

	int caso1 = solve(i + 1, j);
	int caso2 = solve(i, j + 1);
	
	int caso3 = 0;
	if(v[i].sz <= m[j]) caso3 = solve(i + 1, j + 1) + 1;

	return dp[i][j] = max({caso1, caso2, caso3});
}

int main()
{
	memset(dp, -1, sizeof(dp));

	cin >> N >> M;

	for(int i = 0; i < N; i++)
	{
		cin >> v[i].sz >> v[i].val;
	}

	for(int i = 0; i < M; i++)
		cin >> m[i];

	sort(v, v + N);

	sort(m, m + M);

	cout << solve(0, 0) << "\n";
}
# Verdict Execution time Memory Grader output
1 Runtime error 231 ms 275456 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 231 ms 275456 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 231 ms 275456 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -