| UTPC Contest 02-09-24 Div. 1 (Advanced) |
|---|
| Закончено |
You are given $$$N\ (1\leq N\leq 10^5)$$$ pizzas. The $$$i$$$-th pizza consists of $$$s_i\ (2\leq s_i\leq 10^3)$$$ slices, each with side strength $$$q_i\ (1\leq q_i\leq 10^3)$$$ and crust strength $$$c_i (1\leq c_i \leq 10^3)$$$. For example, the below pizza consists of $$$4$$$ slices. Let $$$d_i$$$ be the minimum sum of strengths of slices and crusts that can hold the $$$i$$$-th pizza together, meaning that all the vertices in the picture would be in the same connected component as the other vertices, given that you draw crusts and slices to connect them. For example, the below pizza has $$$s_i = 4, q_i=2, c_i=3$$$. If we were to "connect" the crust and the slice edges this way, it is possible to connect all the vertices together with a total cost of $$$10$$$, although getting a lower $$$d_i$$$ may be possible. The center also counts as a vertex.

Being the pizza addict you are, you want to eat each pizza before it becomes soggy, otherwise, you will feel like you wasted $$$v_i\ (1\leq v_i\leq 10^9)$$$ dollars. However, you can only eat one pizza at a time. What is the minimum total possible amount of money you can feel like you wasted, given that you can eat the pizzas in any order? You start at time $$$t=0$$$, and the pizzas expire at deadline $$$d_i$$$, meaning that the $$$i$$$-th pizza cannot be eaten at $$$t\geq d_i$$$.
The first line contains $$$N$$$, the number of pizzas. Then, there will be $$$N$$$ lines that follow. The $$$i$$$-th line will contain 4 integers, $$$s_i, q_i, c_i, v_i$$$.
The minimum possible amount of money that you can feel like you wasted an integer on its own line.
42 1 1 42 2 3 42 3 2 23 2 1 10
0
| Название |
|---|


