Considering a demand response (DR) based social welfare maximization model, a complementarity problem based on the Karush-Kuhn-Tuker condition is described, which is a non-dual method for determining real-time price for smart grids. The Lagrange multiplier in the dual method, which is used to determine the basic electricity price, is applied in the model. The proposed method computes the optimal electricity consumption, price and production. According to the electricity price, users can arrange their electricity equipment reasonably to reduce the consumption pressure at peak time. The model aims to encourage users to actively participate in the DR and realize peak cutting and valley filling. In addition, the model considers different utility functions representing three types of users. Finally, a Jacobian smoothing version of Newton method is used to solve the model. Statistical simulations of the model validate the rationality and feasibility of the proposed method.