I am just studying Functional Analysis, so I wish to have my solution checked.
Since $X$,$Y$ are subspaces of $[0,1]$ so is $X \cap Y$. Now $X \cap Y \subseteq X$ is closed subspace in $X$. Since if we choose a Cauchy Sequence $\{p_n\}$ in $X \cap Y$, $\{p_n(t)\}$ is bounded for every $t \in [0,1]$ and since $\{p_n\}$ is Cauchy, $\{p_n(t)\}$ converges for every $t\in [0,1]$.
$$p(t)=\lim\limits_{n \to \infty}p_n(t)$$
Since $p_n(0)=0$ for every $n$, we have $p(0)=0$ and since $p_n \in X \cap Y \subseteq C[0,1]$, $p_n$ is bounded and we have $\lim \limits_{n \to \infty} \int _0^1 p_n(t)dt=\int_0^1\lim p_n(t)dt=0$ and hence $X \cap Y$ is closed.
Then by Riesz's lemma, for $0 < \epsilon < 1$, we are guaranteed of an $x \in X$ such that
$$||x-y||\ge 1-\epsilon$$ such that for any $y$ satisfying $y(0)=0, \int_0^1y(t)dt=0$.
Edited the answer before the question was altered to show a weaker existence of the function satisfying the conditions. For a stronger condition, discussions in comments shows that the underlying space should be reflexive for a stronger form of Riesz's Lemma to hold.