Logo
(追記) (追記ここまで)

31340번 - In the cube 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB0000.000%

문제

Taja likes to go to the cafe <<In the cube>> with her friends, since it has very convenient ordering system. To make an order, guest should walk to the automated stand and choose any dishes they likes. There are several such stands and they all are fixed at specific place inside the cafe.

In the cafe guests sit in front of tables, there are $k$ tables. $i$th table cannot serve more than $c_i$ persons. Uncomfortableness of the table position is the sum of the distances from this table to $c_i$ automated stands closest to it.

Formally, cafe is the grid $(0, 0)-(5000, 5000)$. Each cell $(x, y)$ (0ドル \leq x, y \leq 5,000円$) can contain either single automated stand or single table or nothing.

The distance between cells $(x_1, y_1)$ and $(x_2, y_2)$ equals to $|x_2 - x_1| + |y_2 - y_1|$.

You are to arrange the tables in such a way, that total sum of uncomfortablenesses for all tables should be minimal.

입력

First line of the input contains two integers $n$ and $k$ (1ドル \leq n \leq 18,ドル 1ドル \leq k \leq 200$) --- amount of automated stands and tables correspondingly.

Following $n$ lines contain coordinates of $i$th stand: two integers $x_i$ and $y_i$ (0ドル \leq x_i, y_i \leq 5,円 000$).

Next of each $k$ lines contain single integer $c_j$ (1ドル \leq c_j \leq n$) --- number of seats at $j$th table.

출력

Output should contain single integer --- minimal total uncomfortableness.

제한

예제 입력 1

3 4
1 2
4 1
5 4
1
2
3
3

예제 출력 1

20

예제 입력 2

2 10
0 0
5000 5000
1
1
1
1
1
1
1
1
1
1

예제 출력 2

16

힌트

Possible arrangement of the tables for the first sample looks like this:

출처

Contest > Open Cup > 2014/2015 Season > Stage 9: Grand Prix of Udmurtia E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /