DeMarcus Cousins scored 39 points as the Sacramento Kings beat the New York Knicks 135-129.