This page is still under construction.

Parts of this page are still being built. What you see may change.

Multisect

Time limit2sMemory limit512 MB

Summary
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.
Level

Hard8 of 10

Topics
Dynamic programming, Binary search, Probability, Combinatorics
Solved
No attempts yet

Problem

We are developing the world's coolest AI robot product. After a long struggle, we finally sent revision RRCR_{\mathrm{RC}} 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 RPASSR_{\mathrm{PASS}}. To find the revision RBUGR_{\mathrm{BUG}} (RPASS<RBUG≤RRCR_{\mathrm{PASS}} < R_{\mathrm{BUG}} \le R_{\mathrm{RC}}) at which the software started to fail, we have to test revisions one by one.

Assume the following.

  • A test at revision RR passes if R<RBUGR < R_{\mathrm{BUG}} and fails otherwise.
  • Every revision from RPASS+1R_{\mathrm{PASS}} + 1 to RRCR_{\mathrm{RC}} is equally likely to be RBUGR_{\mathrm{BUG}}.

By the first assumption we do not need to test every revision. It is enough to find the revision RR such that the test at R−1R - 1 passes and the test at RR fails. We have KK testing devices, so we can test up to KK 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 KK devices.

A parallel test has a cost. The more tests fail, the more it costs. If ii tests fail in a parallel test, its cost is TiT_i (0≤i≤K0 \le i \le 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 RBUGR_{\mathrm{BUG}} 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?

Input

The input is a single test case in the following format.

RPASS RRC K
T0 T1 ... TK

RPASSR_{\mathrm{PASS}} and RRCR_{\mathrm{RC}} are integers, the revision numbers at which the test passed and failed, respectively, and 1≤RPASS<RRC≤10001 \le R_{\mathrm{PASS}} < R_{\mathrm{RC}} \le 1000. KK (1≤K≤301 \le K \le 30) is the maximum number of revisions that one parallel test can cover. TiT_i is an integer, the cost of a parallel test in which ii tests fail (0≤i≤K0 \le i \le K), and 1≤T0≤T1≤⋯≤TK≤1000001 \le T_0 \le T_1 \le \cdots \le T_K \le 100000.

Output

Print the minimum expected total cost as an irreducible fraction in the form p/q on one line, where pp and qq are coprime integers and q≥1q \ge 1. When the value is an integer, print it with denominator 1 (for example, print 0/1 for 0).

Examples5

  1. Example 1

    Input
    1 10 2
    1 1 1
    
    Expected output
    2/1
    
  2. Example 2

    Input
    1 100 1
    100 100
    
    Expected output
    66400/99
    
  3. Example 3

    Input
    100 200 4
    1 1 2 2 3
    
    Expected output
    116/25
    
  4. Example 4

    Input
    2 3 4
    1 2 3 4 5
    
    Expected output
    0/1
    
  5. Example 5

    Input
    998 1000 4
    10 100 1000 10000 100000
    
    Expected output
    55/1