CF494C.Helping People
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Malek is a rich man. He also is very generous. That's why he decided to split his money between poor people. A charity institute knows n poor people numbered from 1 to n. The institute gave Malek q recommendations. A recommendation is a segment of people like [l, r] which means the institute recommended that Malek gives one dollar to every person whose number is in this segment.
However this charity has very odd rules about the recommendations. Because of those rules the recommendations are given in such a way that for every two recommendation [a, b] and [c, d] one of the following conditions holds:
- The two segments are completely disjoint. More formally either a ≤ b < c ≤ d or c ≤ d < a ≤ b
- One of the two segments are inside another. More formally either a ≤ c ≤ d ≤ b or c ≤ a ≤ b ≤ d.
The goodness of a charity is the value of maximum money a person has after Malek finishes giving his money. The institute knows for each recommendation what is the probability that Malek will accept it. They want to know the expected value of goodness of this charity. So they asked you for help.
You have been given the list of recommendations and for each recommendation the probability of it being accepted by Malek. You have also been given how much money each person initially has. You must find the expected value of goodness.
马莱克是一位富有的人,同时也非常慷慨。因此,他决定将自己的钱分给穷人。一家慈善机构掌握了编号为 1 到 n 的 n 位穷人信息。该机构向马莱克提出了 q 条建议。每条建议是一个人群区间 [l,r],表示该机构建议马莱克向编号落在该区间内的每个人各赠送一美元。
然而,这家慈善机构关于建议的规则十分特殊。正因如此,所有建议均满足如下性质:对任意两条建议 [a,b] 和 [c,d],以下条件之一必然成立:
- 这两个区间完全不相交。更准确地说,要么满足 a≤b<c≤d,要么满足 c≤d<a≤b;
- 其中一个区间完全包含于另一个区间内。更准确地说,要么满足 a≤c≤d≤b,要么满足 c≤a≤b≤d。
该慈善机构的“优良度”定义为:在马莱克完成所有赠款后,所有人中所拥有的钱数的最大值。该机构已知每条建议被马莱克接受的概率,现希望计算该慈善机构优良度的期望值。因此,他们向你寻求帮助。
你已获得所有建议列表,以及每条建议被马莱克接受的概率。你还已知每位穷人初始拥有的钱数。请计算优良度的期望值。
输入格式
In the first line two space-separated integers n, q (1 ≤ n ≤ 105, 1 ≤ q ≤ 5000) are given.
In the second line n space-separated integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 109) are given meaning that person number i initially has a__i dollars.
Each of the next q lines contains three space-separated numbers l__i, r__i, p__i (1 ≤ l__i ≤ r__i ≤ n, 0 ≤ p ≤ 1) where l__i and r__i are two integers describing the segment of recommendation and p__i is a real number given with exactly three digits after decimal point which is equal to probability of Malek accepting this recommendation.
Note that a segment may appear several times in recommendations.
第一行给出两个用空格分隔的整数 n 和 q(1≤n≤105,1≤q≤5000)。
第二行给出 n 个用空格分隔的整数 a1,a2,…,an(0≤ai≤109),表示编号为 i 的人最初拥有 ai 美元。
接下来的 q 行中,每行包含三个用空格分隔的数 li,ri,pi(1≤li≤ri≤n,0≤p≤1),其中 li 和 ri 是描述推荐区间的两个整数,pi 是一个保留三位小数的实数,表示 Malek 接受该推荐的概率。
注意:同一个区间可能在多个推荐中多次出现。
输出格式
Output the sought value. Your answer will be considered correct if its absolute or relative error is less than 10 - 6.
输出所求的值。若您的答案的绝对误差或相对误差小于 10−6,则视为正确。
输入输出样例
输入#1
5 2 1 7 2 4 3 1 3 0.500 2 2 0.500
输出#1
8.000000000
输入#2
5 2 281 280 279 278 282 1 4 1.000 1 4 0.000
输出#2
282.000000000
输入#3
3 5 1 2 3 1 3 0.500 2 2 0.250 1 2 0.800 1 1 0.120 2 2 0.900
输出#3
4.465000000
输入解题思路,AI测评打分。不知道怎么写?