You have been hired as a Temporary Part-Time Assistant Manager of the Executive Municipal Internet Service Provider Administration!
Your job is to set up cell towers to provide internet to homes in The City.
The City can be visualized as a very large rectangular grid. The rows are numbered starting from $$$1$$$, from south to north. The columns are numbered starting from $$$1$$$, from west to east. There are also $$$n$$$ houses on this grid, denoted by $$$(r, c)$$$, where $$$r$$$ is the number of the row the house is in, and $$$c$$$ is the number of the column the house is in.
You are trying to install cell towers for the houses. However, the cell towers have a peculiar set of rules.
A cell tower can only provide signal to a right isosceles triangle that extends south and east from it. More formally, a cell tower at $$$(r, c)$$$ covers all houses $$$(r', c')$$$, such that $$$c \leq c'$$$, and $$$r' + c' \leq r + c$$$.
If a cell tower is set at $$$(3, 1)$$$, it can only provide signal to houses at $$$(3, 1), (2, 1), (1, 1), (2, 2), (1, 2), (1, 3)$$$. Here is a diagram of the range of a cell tower at $$$(3, 1)$$$:
Because the terrain gets rougher the further north you go, the cost of a cell tower is equal to the number of the row it is installed. For instance, installing a cell tower at $$$(3, 1)$$$ has a cost of $$$3$$$.
A cell tower may be installed on top of houses, and it will still provide coverage as usual (despite protests from homeowners).
The City is a bit indecisive about how many cell towers they would like to install. Thus, for every $$$i$$$ from $$$1$$$ to $$$n$$$, find the minimum cost to cover all houses with at most $$$i$$$ cell towers.
The first line contains $$$n$$$, denoting the number of houses. $$$(1 \leq n \leq 2 \cdot 10^5)$$$
The next $$$n$$$ lines contain $$$r, c$$$ $$$(1 \leq r \leq 10^9), (1 \leq c \leq 10^9)$$$, denoting a coordinate of a house.
—
Tests in subtasks are numbered from $$$1−20$$$ with samples skipped. Each test is worth $$$\frac{100}{20}=5$$$ points.
Test $$$1$$$ satisfies $$$n = 1$$$.
Tests $$$2-8$$$ satisfy $$$n \leq 1000$$$, and for each house, $$$r, c \leq 1000$$$.
Tests $$$9-20$$$ satisfy no additional constraints.
Output $$$n$$$ space separated integers, the $$$i$$$th of which is the minimum cost to cover all houses with at most $$$i$$$ cell towers.
21 18 8
15 9
33 51 32 3
5 5 5
52 62 31 31 42 9
8 7 6 6 6
—
Problem Idea: culver0412
Problem Preparation: culver0412
Occurrences: Novice I, Advanced B
| Name |
|---|


