We consider a health authority seeking to allocate annual budgets optimally over time to minimize the discounted social cost of infection(s) evolving in a finite set of R >/= 2 groups. This optimization problem is challenging, since as is well known, the standard epidemiological model describing the spread of disease (SIS) contains a nonconvexity. Standard continuous-time optimal control is of little help, since a phase diagram is needed to address the nonconvexity and this diagram is 2 R dimensional (a costate and state variable for each of the R groups). Standard discrete-time dynamic programming cannot be used either, since the minimized cost function is neither concave nor convex globally. We modify the standard dynamic programming algorithm and show how familiar, elementary arguments can be used to reach conclusions about the optimal policy with any finite number of groups. We show that under certain conditions it is optimal to focus the entire annual budget on one of the R groups at a time rather than divide it among several groups, as is often done in practice; faced with two identical groups whose only di fference is their starting level of infection, it is optimal to focus on the group with fewer sick people. We also show that under certain conditions it remains optimal to focus on one group when faced with a wealth constraint instead of an annual budget.