CF542A Place Your Ad Here

题目描述

有 $n$ 个广告和 $m$ 个电视台,第 $i$ 个广告只能在时间段 $\left[l_i,r_i\right]$ 播放,第 $j$ 个电视台会在时间段 $\left[a_j,b_j\right]$ 播出,并且有 $c_j$ 个人收看。 选择第 $x$ 个广告和第 $y$ 个电视台的收益为 $\left(v-u\right)\times c_y$,其中 $\left[u,v\right]$ 为 $\left[l_x,r_x\right]$ 和 $\left[a_y,b_y\right]$ 的交集。 求最大收益。

输入格式

第一行两个正整数 $n,m$。 接下来 $n$ 行,每行两个非负整数 $l_i,r_i$。 接下来 $m$ 行,每行两个非负整数 $a_j,b_j$ 和一个正整数 $c_j$。

输出格式

第一行一个非负整数代表最大收益。 若最大收益不为 $0$,第二行输出两个正整数 $i,j$,代表选择第 $i$ 个广告和第 $j$ 个电视台时收益最大。 ### 样例解释 选择第二个广告和第一个电视台。 ### 限制与约定 保证 $1\le n,m\le 2\times 10^5$,$0\le l_i\le r_i\le 10^9$,$0\le a_i\le b_i\le 10^9$,$1\le c_i\le 10^9$。

说明/提示

In the first sample test the most optimal solution is to show the second commercial using the first TV channel at time $ [2,4] $ . The efficiency of such solution is equal to $ (4-2)·2=4 $ . In the second sample test Ivan Anatolievich's wish does not meet the options of the TV channel, the segments do not intersect, so the answer is zero.