Pick non-overlapping story intervals to multiply exposed voters' propensities and maximize the right-minus-left propensity gap.
Medium5Dynamic programmingIntervalsSortingNo attempts yetTime limit2sMemory limit512 MBIn an election, fake news is used to keep the other candidate's supporters at home rather than to raise turnout for your own side. The usual method targets a specific group with negative messages about the candidate that group supports, shaped to fit biases the group already holds. This problem models that situation as follows.
Voter j sits at a real position xj on an axis that runs from the political left to the political right, and no voter sits at 0. A voter with xj<0 votes for the left candidate, and a voter with xj>0 votes for the right candidate. Voter j has propensity pj to vote.
Fake news story i is given by an interval [ℓi,ri] and a factor di with 0≤di≤1. When a voter inside [ℓi,ri] is exposed to that story, the propensity of that voter changes from pj to pj×di.
The campaign selects a set of stories to deploy so that no voter falls inside two or more of the selected intervals. A voter inside one selected interval is exposed to that story. After all selected stories are deployed, maximize the total propensity of the voters who vote for the right candidate minus the total propensity of the voters who vote for the left candidate.
The first line contains the number of data sets K (1≤K≤100). The K data sets follow in order.
The first line of a data set contains the number of voters n and the number of fake news stories m (1≤n≤200, 1≤m≤50).
Each of the next n lines contains the position xj and the propensity pj of voter j (−1≤xj≤1, xj=0, 0≤pj≤1). The voters are given in non-decreasing order of xj.
Each of the next m lines contains ℓi, ri and di of story i (−1≤ℓi≤ri≤1, 0≤di≤1). The stories are given in non-decreasing order of ri.
Every number is given with at most two digits after the decimal point. No xj equals any ℓi or any ri.
For each data set, first print Data Set x: on a line of its own, where x is the number of the data set counting from 1.
On the next line print the largest achievable value of the total propensity of the voters for the right candidate minus the total propensity of the voters for the left candidate, rounded to two digits after the decimal point. A value exactly halfway between two outputs rounds away from zero, so 0.375 prints as 0.38 and -0.125 prints as -0.13. Print 0.00 rather than -0.00.
Print a blank line after each data set.