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 n contract options, numbered from 1 to n. The i-th solution has a concentration of xi%, the contract costs wi burles, and Monocarp will be able to sell it for ci burles per liter.
Monocarp is expecting k customers during the first month. Each customer will buy a liter of a y%-solution, where y is a real number chosen uniformly at random from 0 to 100 independently for each customer. More formally, the probability of number y being less than or equal to some t is P(y≤t)=100t.
Monocarp can mix the solution that he signed the contracts with the factory for, at any ratio. More formally, if he has contracts for m solutions with concentrations x1,x2,…,xm, then, for these solutions, he picks their volumes a1,a2,…,am so that i=1∑mai=1 (exactly 1 since each customer wants exactly one liter of a certain solution).
The concentration of the resulting solution is i=1∑mxi⋅ai. The price of the resulting solution is i=1∑mci⋅ai.
If Monocarp can obtain a solution of concentration 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 0.
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 k customers minus the total cost of signing the contracts from the factory.
Print the maximum expected profit Monocarp can achieve.
Monocarp 计划开设一间化学实验室。在第一个月,他将分发某种酸的溶液。
首先,他将与一家本地化工厂签订若干合同。每份合同为 Monocarp 提供无限量的、同一种酸的某浓度溶液。该工厂共提供 n 种合同选项,编号从 1 到 n。第 i 种溶液的浓度为 xi%,合同费用为 wi 卢布,而 Monocarp 可以以每升 ci 卢布的价格将其售出。
Monocarp 预计第一个月将有 k 位顾客。每位顾客将购买一升浓度为 y% 的溶液,其中 y 是一个在区间 [0,100] 上独立均匀随机选取的实数。更准确地说,y 不超过某个 t 的概率为 P(y≤t)=100t。
Monocarp 可以按任意比例混合他通过合同从工厂获得的溶液。更形式化地,若他签订了 m 份合同,对应溶液浓度分别为 x1,x2,…,xm,则他需为这些溶液选定体积 a1,a2,…,am,满足 i=1∑mai=1(因为每位顾客恰好需要一升特定浓度的溶液)。
所得混合溶液的浓度为 i=1∑mxi⋅ai,其售价为 i=1∑mci⋅ai。
若 Monocarp 能配制出浓度恰好为 y% 的溶液,则他将以此浓度配制,并使其售价(即顾客支付价格)最大化;否则,该顾客将不购买任何东西,此时售价视为 0。
Monocarp 希望选择若干合同(可能一个都不签,也可能全部签订),使得期望利润最大化——即所有 k 位顾客所购溶液的总售价的期望值,减去与工厂签订合同的总费用。
请输出 Monocarp 能达到的最大期望利润。
输入格式
The first line contains two integers n and k (1≤n≤5000; 1≤k≤105) — the number of contracts the factory provides and the number of customers.
The i-th of the next n lines contains three integers xi,wi and ci (0≤xi≤100; 1≤wi≤109; 1≤ci≤105) — the concentration of the solution, the cost of the contract and the cost per liter for the customer, for the i-th contract.
第一行包含两个整数 n 和 k(1≤n≤5000;1≤k≤105)—— 分别表示工厂提供的合同数量和客户数量。
接下来的 n 行中,第 i 行包含三个整数 xi、wi 和 ci(0≤xi≤100;1≤wi≤109;1≤ci≤105)—— 分别表示第 i 个合同对应溶液的浓度、该合同的成本,以及该客户每升溶液所需支付的费用。
输出格式
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−6.
Formally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if max(1,∣b∣)∣a−b∣≤10−6.
输出一个实数——Monocarp 能够获得的最大期望利润。
若你的答案的绝对误差或相对误差不超过 10−6,则视为正确。
形式化地,设你的答案为 a,评测系统的答案为 b。当且仅当 max(1,∣b∣)∣a−b∣≤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测评打分。不知道怎么写?