CF1765F.Chemistry Lab

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Monocarp is planning on opening a chemistry lab. During the first month, he's going to distribute solutions of a certain acid.

First, he will sign some contracts with a local chemistry factory. Each contract provides Monocarp with an unlimited supply of some solution of the same acid. The factory provides nn contract options, numbered from 11 to nn. The ii-th solution has a concentration of xi%x_i\%, the contract costs wiw_i burles, and Monocarp will be able to sell it for cic_i burles per liter.

Monocarp is expecting kk customers during the first month. Each customer will buy a liter of a y%y\%-solution, where yy is a real number chosen uniformly at random from 00 to 100100 independently for each customer. More formally, the probability of number yy being less than or equal to some tt is P(y≤t)=t100P(y \le t) = \frac{t}{100}.

Monocarp can mix the solution that he signed the contracts with the factory for, at any ratio. More formally, if he has contracts for mm solutions with concentrations x1,x2,…,xmx_1, x_2, \dots, x_m, then, for these solutions, he picks their volumes a1,a2,…,ama_1, a_2, \dots, a_m so that ∑i=1mai=1\sum \limits_{i=1}^{m} a_i = 1 (exactly 11 since each customer wants exactly one liter of a certain solution).

The concentration of the resulting solution is ∑i=1mxi⋅ai\sum \limits_{i=1}^{m} x_i \cdot a_i. The price of the resulting solution is ∑i=1mci⋅ai\sum \limits_{i=1}^{m} c_i \cdot a_i.

If Monocarp can obtain a solution of concentration y%y\%, then he will do it while maximizing its price (the cost for the customer). Otherwise, the customer leaves without buying anything, and the price is considered equal to 00.

Monocarp wants to sign some contracts with a factory (possibly, none or all of them) so that the expected profit is maximized — the expected total price of the sold solutions for all kk customers minus the total cost of signing the contracts from the factory.

Print the maximum expected profit Monocarp can achieve.

Monocarp 计划开设一间化学实验室。在第一个月,他将分发某种酸的溶液。

首先,他将与一家本地化工厂签订若干合同。每份合同为 Monocarp 提供无限量的、同一种酸的某浓度溶液。该工厂共提供 nn 种合同选项,编号从 11 到 nn。第 ii 种溶液的浓度为 xi%x_i\%,合同费用为 wiw_i 卢布,而 Monocarp 可以以每升 cic_i 卢布的价格将其售出。

Monocarp 预计第一个月将有 kk 位顾客。每位顾客将购买一升浓度为 y%y\% 的溶液,其中 yy 是一个在区间 [0,100][0, 100] 上独立均匀随机选取的实数。更准确地说,yy 不超过某个 tt 的概率为 P(y≤t)=t100P(y \le t) = \frac{t}{100}。

Monocarp 可以按任意比例混合他通过合同从工厂获得的溶液。更形式化地,若他签订了 mm 份合同,对应溶液浓度分别为 x1,x2,…,xmx_1, x_2, \dots, x_m,则他需为这些溶液选定体积 a1,a2,…,ama_1, a_2, \dots, a_m,满足 ∑i=1mai=1\sum \limits_{i=1}^{m} a_i = 1(因为每位顾客恰好需要一升特定浓度的溶液)。

所得混合溶液的浓度为 ∑i=1mxi⋅ai\sum \limits_{i=1}^{m} x_i \cdot a_i,其售价为 ∑i=1mci⋅ai\sum \limits_{i=1}^{m} c_i \cdot a_i。

若 Monocarp 能配制出浓度恰好为 y%y\% 的溶液,则他将以此浓度配制,并使其售价(即顾客支付价格)最大化;否则,该顾客将不购买任何东西,此时售价视为 00。

Monocarp 希望选择若干合同(可能一个都不签,也可能全部签订),使得期望利润最大化——即所有 kk 位顾客所购溶液的总售价的期望值,减去与工厂签订合同的总费用。

请输出 Monocarp 能达到的最大期望利润。

输入格式

The first line contains two integers nn and kk (1≤n≤50001 \le n \le 5000; 1≤k≤1051 \le k \le 10^5) — the number of contracts the factory provides and the number of customers.

The ii-th of the next nn lines contains three integers xi,wix_i, w_i and cic_i (0≤xi≤1000 \le x_i \le 100; 1≤wi≤1091 \le w_i \le 10^9; 1≤ci≤1051 \le c_i \le 10^5) — the concentration of the solution, the cost of the contract and the cost per liter for the customer, for the ii-th contract.

第一行包含两个整数 nn 和 kk(1≤n≤50001 \le n \le 5000;1≤k≤1051 \le k \le 10^5)—— 分别表示工厂提供的合同数量和客户数量。

接下来的 nn 行中,第 ii 行包含三个整数 xix_i、wiw_i 和 cic_i(0≤xi≤1000 \le x_i \le 100;1≤wi≤1091 \le w_i \le 10^9;1≤ci≤1051 \le c_i \le 10^5)—— 分别表示第 ii 个合同对应溶液的浓度、该合同的成本,以及该客户每升溶液所需支付的费用。

输出格式

Print a single real number — the maximum expected profit Monocarp can achieve.

Your answer is considered correct if its absolute or relative error does not exceed 10−610^{-6}.

Formally, let your answer be aa, and the jury's answer be bb. Your answer is accepted if and only if ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}.

输出一个实数——Monocarp 能够获得的最大期望利润。

若你的答案的绝对误差或相对误差不超过 10−610^{-6},则视为正确。

形式化地,设你的答案为 aa,评测系统的答案为 bb。当且仅当 ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6} 时,你的答案被接受。

输入输出样例

  • 输入#1

    2 10
    0 10 20
    100 15 20

    输出#1

    175.000000000000000
  • 输入#2

    2 10
    0 100 20
    100 150 20

    输出#2

    0.000000000000000
  • 输入#3

    6 15
    79 5 35
    30 13 132
    37 3 52
    24 2 60
    76 18 14
    71 17 7

    输出#3

    680.125000000000000
  • 输入#4

    10 15
    46 11 11
    4 12 170
    69 2 130
    2 8 72
    82 7 117
    100 5 154
    38 9 146
    97 1 132
    0 12 82
    53 1 144

    输出#4

    2379.400000000000000

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

首页