CF542A.Place Your Ad Here

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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!

伊万·阿纳托利耶维奇的广告公司正逐渐在城里声名鹊起。

他们已经订购并制作了 nn 个电视广告视频。每个视频均采用特殊方式制作:其色彩与配乐均根据一天中的时段及观众的情绪进行调整。因此,第 ii 个视频仅能在时间区间 [li, ri][l_i,\, r_i] 内播出(无需占用整个区间,但播出时段必须完全落在该区间内)。

现在到了选择电视频道来播放广告的时候了。目前,全市共有 mm 家电视频道在播,其中第 jj 家频道拥有 cjc_j 名观众,并愿意以区间 [aj, bj][a_j,\, b_j] 的时段出售广告播放权。

伊万·阿纳托利耶维奇面临着一项艰难抉择:他必须恰好选择一个视频 ii、恰好选择一家电视频道 jj,并为该视频在该频道上选定一个播放时段 [x, y][x,\, y]。该时段需同时满足:[x, y]⊆[li, ri][x,\, y] \subseteq [l_i,\, r_i] 且 [x, y]⊆[aj, bj][x,\, y] \subseteq [a_j,\, b_j]。

我们定义此次播放的效率为 (y−x)⋅cj(y - x) \cdot c_j —— 即所有该频道观众观看广告所花费的总时长。请帮助伊万·阿纳托利耶维奇选出效率最大的播放方案!

输入格式

The first line contains two integers n and m (1 ≤ n, m ≤ 2·105) — 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 ≤ 109) — 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 ≤ 109, 1 ≤ c__j ≤ 109), characterizing the TV channel.

第一行包含两个整数 nn 和 mm(1≤n,m≤2⋅1051 \leq n, m \leq 2 \cdot 10^5),分别表示商业视频的数量和电视频道的数量。

接下来的 nn 行,每行包含两个整数 lil_i、rir_i(0≤li≤ri≤1090 \leq l_i \leq r_i \leq 10^9),表示第 ii 个视频可播放的时间区间。

接下来的 mm 行,每行包含三个整数 aja_j、bjb_j、cjc_j(0≤aj≤bj≤1090 \leq a_j \leq b_j \leq 10^9,1≤cj≤1091 \leq c_j \leq 10^9),用于描述第 jj 个电视频道。

输出格式

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.

第一行输出一个整数——广播可能达到的最大效率。若不存在使效率严格为正的合法方案,则输出 0。

若最大效率严格为正,则第二行还需输出最有效广播所对应的视频编号 ii(1≤i≤n1 \le i \le n)以及电视频道编号 jj(1≤j≤m1 \le j \le m)。

若存在多个最优解,输出任意一个即可。

输入输出样例

  • 输入#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]. 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.

在第一个样例测试中,最优解是在第一电视频道的时段 [2, 4] 播放第二个广告。该方案的效率为 (4 - 2)·2 = 4。

在第二个样例测试中,伊万·阿纳托利耶维奇的愿望与电视频道的可选时段不匹配,各时段互不相交,因此答案为零。

输入解题思路,AI测评打分。不知道怎么写?

首页