CF542A.Place Your Ad Here

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

They have already ordered and made nn 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 ii -th video can only be shown within the time range of [li,ri][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 mm TV channels broadcasting in the city, the jj -th one has cjc_{j} viewers, and is ready to sell time [aj,bj][a_{j},b_{j}] to broadcast the commercial.

Ivan Anatolyevich is facing a hard choice: he has to choose exactly one video ii and exactly one TV channel jj to broadcast this video and also a time range to broadcast [x,y][x,y] . At that the time range should be chosen so that it is both within range [li,ri][l_{i},r_{i}] and within range [aj,bj][a_{j},b_{j}] .

Let's define the efficiency of the broadcast as value (yx)cj(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!

输入格式

The first line contains two integers nn and mm ( 1<=n,m<=21051<=n,m<=2·10^{5} ) — the number of commercial videos and channels, respectively.

Each of the following nn lines contains two integers lil_{i} , rir_{i} ( 0<=li<=ri<=1090<=l_{i}<=r_{i}<=10^{9} ) — the segment of time when it is possible to show the corresponding video.

Each of the following mm lines contains three integers aja_{j} , bjb_{j} , cjc_{j} ( 0<=aj<=bj<=1090<=a_{j}<=b_{j}<=10^{9} , 1<=cj<=1091<=c_{j}<=10^{9} ), characterizing the TV channel.

输出格式

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 ii ( 1<=i<=n1<=i<=n ) and the number of the TV channel jj ( 1<=j<=m1<=j<=m ) in the most effective broadcast.

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

输入输出样例

  • 输入#1

    2 3
    7 9
    1 4
    2 8 2
    0 4 1
    8 9 3
    

    输出#1

    4
    2 1
    
  • 输入#2

    1 1
    0 0
    1 1 10
    

    输出#2

    0
    

说明/提示

In the first sample test the most optimal solution is to show the second commercial using the first TV channel at time [2,4][2,4] . The efficiency of such solution is equal to (42)2=4(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.

首页