This paper proposes an “out-in degree” Laplacian matrix to dispose the distributed optimization problem for both the continuous-time and discrete-time multiagent systems with the first-order dynamics over a general strongly connected digraph. By making use of the out-degree and in-degree Laplacian matrices of the directed graph, we establish the parameter matrix which possesses some properties similar to the Laplacian matrix of the weight-balanced graph. Such a matrix is constructed to deal with the distributed optimization problem over a directed graph. First, we are concerned with the continuous-time case and sufficient condition for the existence of the distributed optimal protocol. Second, a similar result is established for the discrete-time case with a skillful design of Lyapunov function rather than usage of Young's inequality, which simplifies optimization and convergence analysis.