이경로 2022. 11. 22. 23:39

Difficulty : Gold V

Problem Description

There are N sensors and K centers.

Each center has receivable area, and all sensors should be in these areas.

The output is the minimum length of the sum of the areas.

 

Solution

 

'N' and 'K' are the number of sensors and centers.

'lst' is input array of sensors.

Sort 'lst' to calculate the answer.

 

'dis' is the distance of all sensors. There are 'N-1' distances.

Sort the array to find large distances.

If there are 'K' centers, I can delete 'K-1' distances.

So print the sum of distances except 'K-1' large distances.