Python Python Python Finding Optimal Ad Slot 100 Marks Online Newspaper Website Provides W Q43786230
python python python
Finding the optimal ad slot (100 Marks)
An online newspaper website provides a welcome page to displaysthe ads in the form of slots. These ad slots are in a rectangularshape, but part of ad slot can overlap with another ad slot. Someof the ad slots are purchased by small different companies. A giantcompany wants to purchase the maximum ad slots to display theirads. To achieve this the giant company, need to pay the smallcompanies the purchased ad slot amount. However, the company has alimited budget but want to maximize the area of the ad displayed onthe webpage. It can be assumed the slot which is not sold to anycompany is available for the giant company to display its adwithout paying any amount for the unsold ad slot and can beaggregated with adjacent purchased ad slots.
The webpage can be assumed as an M × N gridwith L ad slots purchased by the small companies.The ith ad slot has its lower-left cornerat (xi, yi), length li (along with the x-axis), width wi (alongwith the y-axis), and purchased amount pi. The ad slot in which thegiant company is going to display its ad should be rectangular inshape.
Please help the company to find the rectangular ad slot with thelargest area which can be purchased without spending more thanC amount of money. (0,0) is the lower left cornerof the slot and (M, N) is the upper right corner. The sides of thead slot should be axis parallel.
The dotted line shows optimal ad slot with area 12(lower left corner at (0,0) and upper right cornerat (4,3).
Input:
4 4 6
3
1 0 2 1 2
2 0 1 4 2
0 3 3 1 4
Output:
12 4
Input Format
Input
•The first line contains three integers M, N, and C.
•The second line contains L.
•Each of the next L lines contains the description of ad slotpurchased by small companies. the ith of these lines have fiveintegers: xi, yi, li, wi, and p
Constraints
-
1 ≤ M, N ≤ 1000
-
0 ≤ C ≤ 1000000000
-
0 ≤ xi ≤ M -li
-
0 ≤ yi ≤ N -wi
-
1 ≤ li,wi
-
1 ≤ pi ≤ 100000
-
1 ≤ L ≤ 1000
Output Format
Output
Print the largest area along with the length and width of therectangular-shaped ad slot that can be used to display ad withoutspending more than C amount of money and amount of money actuallyspent
Sample TestCase 1
Input
4 4 6
3
1 0 2 1 2
2 0 1 4 2
0 3 3 1 4
Output
12 4
Example: Show transcribed image text Example:
Expert Answer
Answer to python python python Finding the optimal ad slot (100 Marks) An online newspaper website provides a welcome page to dis…
OR