Let $([0,1],\Sigma, \lambda)$ be a probability space. For any given $B\in \Sigma$, $K\in [0,1]$ and $f\in L^2(\lambda)$ with $f(x)\in[0,1]$ for all $x $,
$$\max_{A\in \Sigma}\int_A f(x) d\lambda(x)- \int_{A\setminus B} K d\lambda(x)$$
It seems that the optimal $A$ may not necessarily be an upper contour set of form $\{x:f(x)\geq t\}$, because
$$\max_{A\in \Sigma}\int_{A\cap B} f(x) d\lambda(x)+ \int_{A\setminus B} [f(x)-K] d\lambda(x)$$
and if $f,B,K$ are such that $\{x:f(x)\geq t\}$ is convex and $\{x:f(x)\geq K\}\cap B=\emptyset$. Then the optimal $A$ is $\{x:f(x)\geq K\}\cup B$, which may not correspond to an upper contour set.
Could I find any literature for such similar/related problems?
Thanks.