We want to determine the trajectory that an animal must follow in order to maximize its food intake. In this paper, the habitat is supposed to be one-dimensional and infinite. The food distribution on this habitat can be arbitrary (continuous or not). The animal has a limited time T available to exploit the food resource and to return to its starting point. We find explicitly the optimal strategy, i. e. , the stopping point and the velocity at each point of the traversed segment. Mathematically, we approximate the food distribution by a piecewise constant distribution, and we solve explicitly the approximate problem by using the techniques of the calculus of variations based on convexity hypotheses. Using then a density argument we recover the solution of the general problem.