Skip to content

P14839 THUPC2026 集合

Step 1

I think we can split the 2 conditions: 1. choose set \(S\) from \(S \subseteq A\) such that consecutive elements differ by at most \(a\). 2. choose set \(T\) from \(T \subseteq B\) such that consecutive elements differ by at must b. 3. Take the union \(C = S \cup T\) and minimize \(|C|\).

$\(|C| = |S| + |T| - |S \cap T|\)$ If we already have a minimal \(S\) and \(T\), would I ever add elements to \(S\) or \(T\) for the union to be smaller? No, that wouldn't change stuff.

Reduced problem: Find minimal \(S\) and \(T\) such that we maximize \(|S \cap T|\).

Step 2

We can only consider which elements should we choose for \(A \cap B\). The rest can be seen as transition weights (they can be chosen greedily.)