Dumbledore allowed the entirety of House Slytherin to believe they'd won the cup, then awarded an arbitrary number of points to kids from his former house (for violating his explicit instructions) in order to snatch the fruits of a year's effort from them in front of their peers.