Suppose $A \subseteq \mathbb{N}$ is such that $\displaystyle{\sum\_{n \in A} n^{-1}} = \infty$. Suppose $B \subseteq \mathbb{N}$ is infinite.


Is there a set $X \subseteq [1,\infty)$ and a increasing function $f:[1,\infty) \rightarrow [1,\infty)$ with $\displaystyle{\lim\_{x \rightarrow \infty} \dfrac{\ln f(x)}{\ln x}=0}$ such that


$$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all } x \in X$$
and
$$
\lceil X \rceil \cap B = \{ \lceil x \rceil : x \in X \} \cap B \text{ is infinite}?
$$


Here are some observations about the problem.


If $A = B = \mathbb{N}$, we can take $X = \mathbb{N}$ and $f(x)=2$.


Suppose we try $f(x) = (\ln x)^2$. Let's try to figure out which values of $x$ satisfy $|A\cap(x,2x]| \geq \dfrac{x}{f(x)}.$ Seeking a contradiction suppose, $|A\cap(x\_k,2x\_k]| < \dfrac{x\_k}{f(x\_k)}$ for all large $x\_k=2^k$, $k \in \mathbb{N}$. Then
\begin{align}
\sum\_{n \in A} n^{-1} &\ll \sum\_{k=1}^{\infty} \sum\_{n \in A\cap(x\_k,2x\_k] } n^{-1} 
\ll \sum\_{k=1}^{\infty} x\_k^{-1} |A\cap(x\_k,2x\_k]| \\
&\ll \sum\_{k=1}^{\infty} f(x\_k)^{-1} 
= (\ln 2)^{-2} \sum\_{k=1}^{\infty} k^{-2} < \infty,
\end{align}
which contradicts $\displaystyle{\sum\_{n \in A} n^{-1}} = \infty$.
So we have 
$$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x$ in some infinite subset of $\{2^k : k \in \mathbb{N}\}$}$$
Now fix $r \in (1,2]$. Seeking a contradiction suppose, $|A\cap(x\_k,2x\_k]| < \dfrac{x\_k}{f(x\_k)}$ for all large $x\_k=r^k$, $k \in \mathbb{N}$. Then
\begin{align}
\sum\_{n \in A} n^{-1} &\ll \sum\_{k=1}^{\infty} \sum\_{n \in A\cap(x\_k,2x\_k] } n^{-1} 
\ll \sum\_{k=1}^{\infty} x\_k^{-1} |A\cap(x\_k,2x\_k]| \\
&\ll \sum\_{k=1}^{\infty} f(x\_k)^{-1} 
= (\ln r)^{-2} \sum\_{k=1}^{\infty} k^{-2} < \infty,
\end{align}
which contradicts $\displaystyle{\sum\_{n \in A} n^{-1}} = \infty$.
So we have 
$$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x$ in some infinite subset of $\{r^k : k \in \mathbb{N}\}$}$$
Considering all values of $r$ together, we have that there is a set $X$ which contains an infinite subset of $\{r^k : k \in \mathbb{N}\}$ for all $r \in (1,2]$ and for which
$$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x \in X$}.$$
If we fix $r \in (1,2]$ again. We can run the argument above with $x\_k$ any sequence with $r^k \leq x\_k \leq 2^k$ for all large $k$. This makes our set $X$ even bigger. The question is whether $\lceil X \rceil \cap B$ is infinite.


Suppose we try the different function $f(x) = \exp(\sqrt{\ln x})$. Let's try to figure out which values of $x$ satisfy $|A\cap(x,2x]| \geq \dfrac{x}{f(x)}.$ Seeking a contradiction suppose, $|A\cap(x\_k,2x\_k]| < \dfrac{x\_k}{f(x\_k)}$ for all large $x\_k=\exp((2\ln k)^2)$, $k \in \mathbb{N}$. Then
\begin{align}
\sum\_{n \in A} n^{-1} &\ll \sum\_{k=1}^{\infty} \sum\_{n \in A\cap(x\_k,2x\_k] } n^{-1} 
\ll \sum\_{k=1}^{\infty} x\_k^{-1} |A\cap(x\_k,2x\_k]| \\
&\ll \sum\_{k=1}^{\infty} f(x\_k)^{-1} 
= \sum\_{k=1}^{\infty} k^{-2} < \infty,
\end{align}
which contradicts $\displaystyle{\sum\_{n \in A} n^{-1}} = \infty$.
So we have 
$$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x$ in some infinite subset of $\{\exp((2\ln k)^2) : k \in \mathbb{N}\}$}$$
We can run the argument with $x\_k$ being any sequence with $\exp((2\ln k)^2) \leq x\_k \leq 2^k$ for all large $k$. So we can run it with $x\_k = r^k$ for any $r \in (1,2]$, for example. We get that 
$$|A\cap(x,2x]| \geq \dfrac{x}{f(x)} \quad \text{for all $x \in X$}$$
where $X$ is an even bigger set than in the previous example. However, it's still not clear that $\lceil X \rceil \cap B$ is infinite.



Does the divergence of the sum of reciprocals of a set of integers imply this density statement about the set?
No. This kind of counterexample is fairly standard (see for example literature on divergence in subsequence ergodic theorems). You make $A$ consist of an interval, a larger gap, a LARGER interval, an EVEN LARGER gap etc and let $B$ consist of the midpoints of the gaps. 


For example 
$$
A=\bigcup\_{n=1}^\infty [2^{2^{2n}},2^{2^{2n+1}}]
$$
and
$$
B=\{2^{2^{2n}-1}\colon n\in\mathbb N\}.
$$


Notice that if $x=2^{2^{2n}-1}$ then $|A\cap [x,2x]| \le 2^{2^{2n-1}}=\sqrt{2x}$.
In particular, if $f(x)$ grows slower than any power of $x$ then
for large $\lceil x\rceil\in B$, we have $|A\cap [x,2x]|\not> x/f(x)$.


