| UTPC Contest 10-11-24 Div. 1 (Advanced) |
|---|
| Закончено |
Beggsie the chicken needs you to solve a problem in Farmer John's farm. The farm can be represented as a two dimensional grid. Further, there are $$$n$$$ eggs on the farm, where the $$$i$$$th egg is at position $$$(x_i, y_i)$$$.
The compactness of the farm can be represented by the sum of Manhattan distances between each pair of eggs. Formally, if $$$(x_i', y_i')$$$ is the current position of the $$$i$$$th egg, then the compactness given by $$$\sum\limits_{i=1}^n \sum\limits_{j=i+1}^n (|x_i' - x_j'| + |y_i' - y_j'|)$$$.
There are $$$d$$$ days, and during the $$$i$$$th day there are $$$s_i$$$ seconds. During each second, Beggsie can choose to move a single egg in one of the four cardinal directions, or to not move anything. Now, let $$$c_i$$$ be the compactness of the farm after day $$$i$$$. Farmer John wants Beggsie to minimize the value of $$$\sum\limits_{i=1}^d c_i$$$. Please help Beggsie by finding the minimum such value!
The first line of input will contain $$$n$$$, $$$d$$$. ($$$1 \leq n, d \leq 2 \cdot 10^5$$$) — the number of eggs in the farm, and the number of days during which Beggsie can move eggs.
The $$$i$$$th of the next $$$n$$$ lines of input will contain $$$x_i$$$ and $$$y_i$$$ ($$$1 \leq x_i, y_i \leq 10^6$$$) — the position of the $$$i$$$th egg in the farm.
The last line of input will contain $$$d$$$ space-separated integers $$$s_1, s_2, \cdots, s_n$$$ ($$$1 \leq s_i \leq 10^6$$$) — the number of seconds in each day.
Output a single integer, denoting the minimum value of $$$\sum\limits_{i=1}^d c_i$$$. Since this integer may be extremely large, output it modulo $$$998244353$$$.
2 31 14 31 1 1
9
3 33 12 15 12 1 1
2
5 31 14 56 32 39 83 4 7
126
| Название |
|---|


