CF1842E.Tenzing and Triangle

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn pairwise-distinct points and a line x+y=kx+y=k on a two-dimensional plane. The ii-th point is at (xi,yi)(x_i,y_i). All points have non-negative coordinates and are strictly below the line. Alternatively, 0≤xi,yi,xi+yi<k0 \leq x_i,y_i, x_i+y_i \lt k.

Tenzing wants to erase all the points. He can perform the following two operations:

  1. Draw triangle: Tenzing will choose two non-negative integers aa, bb that satisfy a+b<ka+b \lt k, then all points inside the triangle formed by lines x=ax=a, y=by=b and x+y=kx+y=k will be erased. It can be shown that this triangle is an isosceles right triangle. Let the side lengths of the triangle be ll, ll and 2l\sqrt 2 l respectively. Then, the cost of this operation is l⋅Al \cdot A.

    The blue area of the following picture describes the triangle with a=1,b=1a=1,b=1 with cost =1⋅A=1\cdot A.

  2. Erase a specific point: Tenzing will choose an integer ii that satisfies 1≤i≤n1 \leq i \leq n and erase the point ii. The cost of this operation is cic_i.

Help Tenzing find the minimum cost to erase all of the points.

平面上有 nn 个两两互异的点,以及一条直线 x+y=kx+y=k。第 ii 个点位于 (xi,yi)(x_i,y_i)。所有点的坐标均为非负数,且严格位于该直线下方,即满足 0≤xi,yi0 \leq x_i, y_i 且 xi+yi<kx_i + y_i < k。

登真希望擦除所有这些点。他可以执行以下两种操作:

  1. 绘制三角形:登真选择两个非负整数 aa、bb,满足 a+b<ka + b < k,然后擦除由直线 x=ax = a、y=by = b 和 x+y=kx + y = k 所围成的三角形内部的所有点。可以证明,该三角形是一个等腰直角三角形。设该三角形的两条直角边长均为 ll,斜边长为 2 l\sqrt{2}\,l,则该操作的代价为 l⋅Al \cdot A。

    下图中蓝色区域表示当 a=1a = 1、b=1b = 1 时对应的三角形,其代价为 1⋅A1 \cdot A。

  2. 擦除特定点:登真选择一个满足 1≤i≤n1 \leq i \leq n 的整数 ii,擦除第 ii 个点。该操作的代价为 cic_i。

请帮助登真求出擦除所有点所需的最小总代价。

输入格式

The first line of the input contains three integers nn, kk and AA (1≤n,k≤2⋅1051\leq n,k\leq 2\cdot 10^5, 1≤A≤1041\leq A\leq 10^4) — the number of points, the coefficient describing the hypotenuse of the triangle and the coefficient describing the cost of drawing a triangle.

The following nn lines of the input the ii-th line contains three integers xi,yi,cix_i,y_i,c_i (0≤xi,yi,xi+yi<k0\leq x_i,y_i,x_i+y_i \lt k, 1≤ci≤1041\leq c_i\leq 10^4) — the coordinate of the ii-th points and the cost of erasing it using the second operation. It is guaranteed that the coordinates are pairwise distinct.

输入的第一行包含三个整数 nn、kk 和 AA(1≤n,k≤2⋅1051\leq n,k\leq 2\cdot 10^5,1≤A≤1041\leq A\leq 10^4)——分别表示点的数量、描述三角形斜边的系数,以及绘制一个三角形的代价系数。

接下来的 nn 行中,第 ii 行包含三个整数 xi,yi,cix_i,y_i,c_i(0≤xi,yi,xi+yi<k0\leq x_i,y_i,x_i+y_i \lt k,1≤ci≤1041\leq c_i\leq 10^4)——表示第 ii 个点的坐标及其使用第二种操作擦除该点的代价。保证所有坐标的两两互不相同。

输出格式

Output a single integer —the minimum cost needed to erase all of the points.

输出一个整数——擦除所有点所需的最小代价。

输入输出样例

  • 输入#1

    4 6 1
    1 2 1
    2 1 1
    1 1 1
    3 2 6

    输出#1

    4
  • 输入#2

    6 7 1
    4 2 1
    3 3 1
    5 1 4
    3 2 5
    4 1 1
    0 6 4

    输出#2

    4
  • 输入#3

    10 4 100
    0 0 1
    0 1 1
    0 2 50
    0 3 200
    1 0 1
    1 1 1
    1 2 1
    2 0 200
    2 1 200
    3 0 200

    输出#3

    355

说明/提示

The picture of the first example:

Tenzing do the following operations:

  1. draw a triangle with a=3,b=2a=3,b=2, the cost =1⋅A=1=1\cdot A=1.
  2. erase the first point, the cost =1=1.
  3. erase the second point, the cost =1=1.
  4. erase the third point, the cost =1=1.

The picture of the second example:

第一个示例的图示:

丹增执行以下操作:

  1. 绘制一个边长为 a=3a=3、b=2b=2 的三角形,花费 =1⋅A=1=1\cdot A=1。
  2. 擦除第一个点,花费 =1=1。
  3. 擦除第二个点,花费 =1=1。
  4. 擦除第三个点,花费 =1=1。

第二个示例的图示:

输入解题思路,AI测评打分。不知道怎么写?

首页