VK Cup 2015 - Round 3 (unofficial online mirror, Div. 1 only)
A
Place Your Ad Here
Codeforces
2400
原题
←B →
翻译中…

Ivan Anatolyevich's agency is starting to become famous in the town.

翻译中…

They have already ordered and made $*n*$ TV commercial videos. Each video is made in a special way: the colors and the soundtrack are adjusted to the time of the day and the viewers' mood. That's why the $*i*$-th video can only be shown within the time range of $[*l*_{*i*}, *r*_{*i*}]$ (it is not necessary to use the whole segment but the broadcast time should be within this segment).

翻译中…

Now it's time to choose a TV channel to broadcast the commercial. Overall, there are $*m*$ TV channels broadcasting in the city, the $*j*$-th one has $*c*_{*j*}$ viewers, and is ready to sell time $[*a*_{*j*}, *b*_{*j*}]$ to broadcast the commercial.

翻译中…

Ivan Anatolyevich is facing a hard choice: he has to choose exactly one video $*i*$ and exactly one TV channel $*j*$ to broadcast this video and also a time range to broadcast $[*x*, *y*]$. At that the time range should be chosen so that it is both within range $[*l*_{*i*}, *r*_{*i*}]$ and within range $[*a*_{*j*}, *b*_{*j*}]$.

翻译中…

Let's define the efficiency of the broadcast as value $(*y* - *x*)·*c*_{*j*}$ — the total sum of time that all the viewers of the TV channel are going to spend watching the commercial. Help Ivan Anatolyevich choose the broadcast with the maximum efficiency!

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 2·10^{5}$) — the number of commercial videos and channels, respectively.

翻译中…

Each of the following $*n*$ lines contains two integers $*l*_{*i*}$, $*r*_{*i*}$ ($0 ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ 10^{9}$) — the segment of time when it is possible to show the corresponding video.

翻译中…

Each of the following $*m*$ lines contains three integers $*a*_{*j*}$, $*b*_{*j*}$, $*c*_{*j*}$ ($0 ≤ *a*_{*j*} ≤ *b*_{*j*} ≤ 10^{9}$, $1 ≤ *c*_{*j*} ≤ 10^{9}$), characterizing the TV channel.

翻译中…

Output

翻译中…

In the first line print an integer — the maximum possible efficiency of the broadcast. If there is no correct way to get a strictly positive efficiency, print a zero.

翻译中…

If the maximum efficiency is strictly positive, in the second line also print the number of the video $*i*$ ($1 ≤ *i* ≤ *n*$) and the number of the TV channel $*j*$ ($1 ≤ *j* ≤ *m*$) in the most effective broadcast.

翻译中…

If there are multiple optimal answers, you can print any of them.

翻译中…

Note

翻译中…

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.

翻译中…

样例

Input #1
2 3
7 9
1 4
2 8 2
0 4 1
8 9 3
Output #1
4
2 1
InputCopy OutputCopy
Input #2
1 1
0 0
1 1 10
Output #2
0
InputCopy OutputCopy
题目信息
题号
542A
时间限制
2 s
内存限制
256 MB
标签
数据结构
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。