atcoder#ARC122F. [ARC122F] Domination
[ARC122F] Domination
Score : points
Problem Statement
There are red stones and blue stones on a two-dimensional plane. The -th red stone is at coordinates , and the -th blue stone is at . There may be multiple stones at the same coordinates.
You can choose a blue stone and move it to anywhere you like, any number of times. The cost of moving a blue stone from to is .
You want to meet the following condition:
- For every , there are or more blue stones to the upper right of the -th red stone. More formally, there are or more indices such that and , where are the coordinates of the -th blue stone after your operations.
Find the minimum total cost needed to achieve your objective.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 2 1
0 0
2 0
0 2
1 0
0 1
2
The optimal moves are as follows.
- Move the first blue stone to , for the cost of .
- Move the second blue stone to , for the cost of .
3 2 2
0 0
2 0
0 2
1 0
0 1
6
The optimal moves are as follows.
- Move the first blue stone to , for the cost of .
- Move the second blue stone to , for the cost of .
10 10 3
985971569 9592031
934345597 151698665
212173157 492617927
623299445 288193327
381549360 462770084
681791249 242910920
569404932 353061961
357882677 463919940
110389433 533715995
9639432 700209424
771167518 75925290
439954587 566974581
738467799 122646638
267815107 900808287
886340750 70087431
434010239 822484872
388269208 879859813
393002209 874330449
154134229 924857472
667626345 460737380
1165266772