302794: CF542A. Place Your Ad Here
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Place Your Ad Here
题意翻译
【问题描述】 有N个广告和M个电视台,第i个广告只能在[li,ri]内播放,第j个电视台会在时间段[aj,bj]播出,并且有cj个人收看。选择第x个广告和第y个电视台的收益为(v-u)*cy,其中[u,v]为[lx,rx]和[ay,by]的交集 求最大收益 【输入格式】 第一行两个正整数N,M 接下来N行,每行两个非负整数li,ri(li<=ri<=10^9) 接下来M行,每行两个非负整数aj,bj(aj<=bj<=10^9)和一个正整数cj(cj<=10^9) 【样例输入】 2 3 8 10 2 5 3 9 2 1 5 1 9 10 3 【样例输出】 4 【样例解释】 选择第二个广告和第一个电视台 【数据规模】 对于100%的数据, n<=200000,m<=200000题目描述
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!输入输出格式
输入格式
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.
输出格式
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.
输入输出样例
输入样例 #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