The problem of finding the distribution of functional of a trajectory of a particle executing a random walk in a disordered medium containing both traps and obstacles is considered. As a model of a disordered medium, the Schirmacher model, which is the combination of the random barriers model and the multiple-trapping model, is used. Forward and backward Feynman-Kac equations with the boundary conditions at discontinuity points are formulated. As an example, the distribution of the residence time in a half-space is obtained. It is shown that the anomalous subdiffusion due to traps and that due to obstacles give very different distributions.