Editorial for WC '17 Contest 1 S1 - On the Rocks
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
There are several approaches to this problem, such as first determining which team will score points and then counting how many points they should score, or sorting all stones in increasing order of distance from the button and then counting the number of closest stones which all belong to the same team.
One approach with a simple implementation involves the insight that every stone simply contributes point for its team if there are no stones from the opposing team which are closer to the button than it. For each team, we can iterate over each of its stones, and then determine whether or not it satisfies this condition by iterating over all of the other team's stones and checking if at least one of them has a smaller distance value.
Comments