Given a hidden failing revision among n candidates and up to K simultaneous tests per round, find the strategy that minimizes expected total cost when a round with i failures costs T_i.
Hard8Dynamic programmingBinary searchProbabilityCombinatoricsNo attempts yetTime limit2sMemory limit512 MBWe are developing the world's coolest AI robot product. After a long struggle, we finally sent revision RRC of the product to the QA team as a release candidate. They reported that some tests failed. Because we were too lazy to set up a continuous integration system, we have no idea when the software broke. We only know that every test passed at the past revision RPASS. To find the revision RBUG (RPASS<RBUG≤RRC) at which the software started to fail, we have to test revisions one by one.
Assume the following.
By the first assumption we do not need to test every revision. It is enough to find the revision R such that the test at R−1 passes and the test at R fails. We have K testing devices, so we can test up to K different revisions at the same time. We call this a parallel test. Because of the testing environment, we cannot start new tests until the current parallel test finishes, even when it does not use all K devices.
A parallel test has a cost. The more tests fail, the more it costs. If i tests fail in a parallel test, its cost is Ti (0≤i≤K). When we run several parallel tests, the total cost is the sum of their costs.
We want to minimize the total cost of determining RBUG by carefully choosing how many revisions, and which ones, to test in each parallel test. What is the minimum expected total cost under an optimal strategy?
The input is a single test case in the following format.
RPASS RRC K
T0 T1 ... TK
RPASS and RRC are integers, the revision numbers at which the test passed and failed, respectively, and 1≤RPASS<RRC≤1000. K (1≤K≤30) is the maximum number of revisions that one parallel test can cover. Ti is an integer, the cost of a parallel test in which i tests fail (0≤i≤K), and 1≤T0≤T1≤⋯≤TK≤100000.
Print the minimum expected total cost as an irreducible fraction in the form p/q on one line, where p and q are coprime integers and q≥1. When the value is an integer, print it with denominator 1 (for example, print 0/1 for 0).