I don't understand how S ranks work
http://matchhistory.na.leagueoflegends.com/en/#match-details/NA1/2497504356/227803662?tab=overview
http://matchhistory.na.leagueoflegends.com/en/#match-details/NA1/2498551645/227803662?tab=overview
The first was an S rank. The second was only an A+. Is this grading system basically random?