This paper addresses how to select observed agents and controlled agents in a multi-agent system such that the system is structurally controllable with minimum cost of control and measurement. Firstly, we model the design issue as a minimum cost control configuration (MCCC) design problem of a bilinear system. Next, a necessary condition for the solvability of MCCC is derived. Then, an algorithm is given to provide the optimal solution to MCCC. This algorithm is based on the directed acyclic graph decomposition of the system graph, the Dulmage-Mendelson decomposition of the system bipartite graph, and verifying coprime paths. We use a new graph called dynamic graph to verify the coprime paths, which can avoid infinite verification loops when there are cycles in the system graph. We also prove that this algorithm has polynomial computational complexity. Finally, an example is given to illustrate the validity of the algorithm.