Editorial for Baltic OI '12 P4 - Fireworks in RightAngleles
Submitting an official solution before solving the problem yourself is a bannable offence.
First we can see that there is no difference between positive and negative
If fireworks is in point
- citizen must walk distance
.
So if we have fixed firework position then all that is needed to calculate total distance for multiple intersections simultaneously are (for each region):
- Number of citizens in this region;
- Sum of x coordinates;
- Sum of y coordinates.
Which firework positions can give minimal total distance? As all distance functions are linear (while point do not change its region) then sum is also linear function therefore total function minimum (or one of them) will be when one of citizen house location is positioned on border between different regions. We can create all events (there are
Comments