In the smart grid, users, power suppliers and Power Market Scheduling Center are the main participants. In view of the increasing demand response ability of users, an identification mechanism of punishing malicious users and unstable power providers while incenting nonmalicious users is proposed, and an optimization model to maximize social welfare is considered to study the real-time pricing problem in smart grid managed by PMSC. The model is analyzed by Lagrange dual method and finally solved by heuristic algorithm to obtain the optimal electricity price and power demand. The simulation results show that the algorithm can converge well and the reliability and stability of power system are optimized under the dual regulation of penalty and incentive. In addition, there is a positive correlation between the incentive factor and users' utility and social welfare within proper range.