답안 #927531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927531 2024-02-15T02:58:26 Z Gromp15 Exhibition (JOI19_ho_t2) C++17
50 / 100
1000 ms 5832 KB
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define db double
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rint(l, r) uniform_int_distribution<int>(l, r)(rng)
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
struct seg {
	int N; vector<int> tree;
	seg(int n) : N(1<<(__lg(n))), tree(2*N) {}
	void update(int pos, int x) {
		for (int i = pos+N; i; i >>= 1) {
			ckmax(tree[i], x);
		}
	}
	int query(int node, int nl, int nr, int ql, int qr) {
		if (ql > nr || qr < nl) return 0;
		if (ql <= nl && nr <= qr) return tree[node];
		int mid = (nl+nr)/2;
		return max(query(node*2, nl, mid, ql, qr), query(node*2+1, mid+1, nr, ql, qr));
	}
	int query(int l, int r) {
		return query(1, 0, N-1, l, r);
	}
};
void test_case() {
	int n, m;
	cin >> n >> m;
	vector<int> X, Y;
	vector<ar<int, 2>> a(n);
	for (auto &x : a) cin >> x[0] >> x[1], X.push_back(x[0]), Y.push_back(x[1]);
	vector<int> s(m);
	for (int &x : s) cin >> x, X.push_back(x);
	sort(all(X));
	sort(all(Y));
	X.erase(unique(all(X)), X.end());
	Y.erase(unique(all(Y)), Y.end());
	for (auto &x : a) {
		x[0] = lower_bound(all(X), x[0]) - X.begin();
		x[1] = lower_bound(all(Y), x[1]) - Y.begin();
	}
	for (int &x : s) {
		x = lower_bound(all(X), x) - X.begin();
	}
	sort(all(a), [&](auto &A, auto &B) { return A[1] != B[1] ? A[1] < B[1] : A[0] < B[0]; });
	sort(all(s));
	vector<bool> dp(m+1);
	dp[0] = 1;
	for (int i = n-1; i >= 0; i--) {
		vector<bool> dp2(dp);
		auto [x, y] = a[i];
		for (int j = 0; j < m; j++) if (dp[j]) {
			int use = s[m - j - 1];
			if (use >= x) {
				dp2[j+1] = 1;
			}
		}
		swap(dp, dp2);
		if (dp[m]) {
			cout << m << '\n';
			return;
		}
	}
	for (int i = m-1; i >= 0; i--) if (dp[i]) {
		cout << i << '\n';
		return;
	}
 
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
//    cin >> t;
    while (t--) test_case();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 3 ms 344 KB Output is correct
26 Correct 3 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 2 ms 476 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 3 ms 344 KB Output is correct
26 Correct 3 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 2 ms 476 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Execution timed out 1024 ms 5832 KB Time limit exceeded
39 Halted 0 ms 0 KB -