Let $X = 2^\mathbb{N}$ and $Y = \mathbb{R}^+$ (i.e. the non-negative numbers). Is there a topology in which functions similar to $f : X \to Y$, $ f(A) = \begin{cases} \frac{1}{|A|}, & |A| < \infty \\ \\ \ \ 0, & |A| \not<\infty \end{cases}$ or $g(A) = f(A \cap \{2k \mid k \in \mathbb{N}\})$ would be continuous, but $ h(A) = \begin{cases} \frac{1}{|A|}, & |A| < \infty \\ \\ \ \ 1, & |A| \not<\infty \end{cases}$ would not? (For $Y$ take the standard topology on $\mathbb{R}$.)
Is it possible for $X$ to be compact with such topology? The context is proving that some functions defined on $X$ attain the minimum/maximum value and I am wondering if it could be done via topology. The functions I am talking about are similar to $F(A) = \sum_k [\text{if }B_k \subseteq A\text{ then }b_k\text{ else }0]$
where $(B_k)$ is some countable family of finite sets, and we know that $F$ is bounded, i.e. there exists $M$ such that $|F(A)| < M$ for every $A$. I will appreciate comments on other approaches too.
Thanks in advance!