Yes or No?
InterviewTime limit1sMemory limit128 MB
Pick between l and r questions to answer Yes, maximizing the sum of per-question expected correct probabilities, and report the maximum expectation to two decimals.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Sorting, Greedy, Probability
- Solved
- No attempts yet
Problem
Multiple-choice tests are easy to grade, so they are popular with some teachers. The simplest form is the true/false, or yes/no, question.
You are taking a yes/no test. For each question you have an a priori estimate of how likely each answer is to be correct. For question you believe the answer is “Yes” with probability and “No” with probability .
If the questions were independent you would simply pick whichever of and is larger. However, this teacher dislikes a lopsided answer key, and you know that the number of “Yes” answers is always between and inclusive, for some .
You must therefore decide which questions to answer “Yes” — answering “Yes” at least times and at most times — so as to maximize the expected number of questions you get right. Output that maximum expected number of correct answers.
Input
The first line contains the number of data sets . Then follow data sets of the following form.
The first line of each data set contains three integers , where is the total number of questions, is the minimum number of questions answered “Yes”, and is the maximum.
This is followed by lines, each containing one fractional number for the corresponding question .
Output
For each data set, first output Data Set x: on a line by itself, where is its number. Then output the maximum expected number of questions you can get right subject to all the constraints, rounded to two decimals.