CF1842E.Tenzing and Triangle
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n pairwise-distinct points and a line x+y=k on a two-dimensional plane. The i -th point is at (xi,yi) . All points have non-negative coordinates and are strictly below the line. Alternatively, 0≤xi,yi,xi+yi<k .
Tenzing wants to erase all the points. He can perform the following two operations:
-
Draw triangle: Tenzing will choose two non-negative integers a , b that satisfy a+b<k , then all points inside the triangle formed by lines x=a , y=b and x+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 l , l and 2l respectively. Then, the cost of this operation is l⋅A .The blue area of the following picture describes the triangle with a=1,b=1 with cost =1⋅A .
-
Erase a specific point: Tenzing will choose an integer i that satisfies 1≤i≤n and erase the point i . The cost of this operation is ci .
Help Tenzing find the minimum cost to erase all of the points.
输入格式
The first line of the input contains three integers n , k and A ( 1≤n,k≤2⋅105 , 1≤A≤104 ) — the number of points, the coefficient describing the hypotenuse of the triangle and the coefficient describing the cost of drawing a triangle.
The following n lines of the input the i -th line contains three integers xi,yi,ci ( 0≤xi,yi,xi+yi<k , 1≤ci≤104 ) — the coordinate of the i -th points and the cost of erasing it using the second operation. It is guaranteed that the coordinates are pairwise distinct.
输出格式
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:
- draw a triangle with a=3,b=2 , the cost =1⋅A=1 .
- erase the first point, the cost =1 .
- erase the second point, the cost =1 .
- erase the third point, the cost =1 .
The picture of the second example: