当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5419:Victor and Toys

题目描述
Victor has $n$ toys, numbered from $1$ to $n$. The beauty of the $i$-th toy is $w_i$.

Victor has a sense of math and he generates $m$ intervals, the $i$-th interval is $[l_i,r_i]$. He randomly picks $3$ numbers $i,j,k(1\leq i < j < k \leq m)$, and selects all of the toys whose number are no less than $\max(l_i,l_j,l_k)$ and no larger than $\min(r_i,r_j,r_k)$. Now he wants to know the expected sum of beauty of the selected toys, can you help him?
输入解释
The first line of the input contains an integer $T$, denoting the number of test cases.

In every test case, there are two integers $n$ and $m$ in the first line, denoting the number of the toys and intervals.

The second line contains $n$ integers, the $i$-th integer $w_i$ denotes that the beauty of the $i$-th toy.

Then there are $m$ lines, the $i$-th line contains two integers $l_i$ and $r_i$.

$1\leq T\leq 10$.

$1\leq n,m\leq 50000$.

$1\leq w_i\leq 5$.

$1\leq l_i\leq r_i\leq n$.
输出解释
Your program should print $T$ lines : the $i$-th of these denotes the answer of the $i$-th case.

If the answer is an integer, just print a single interger, otherwise print an irreducible fraction like $p/q$.
输入样例
1
3 4
1 1 5
2 3
1 3
3 3
1 1
输出样例
5/4
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5419

最后修改于 2020-10-25T23:22:30+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/131072K(Java/Others)