In this problem, you need to solve a well-known NP problem - the quadratic integer programming problem.
Quadratic integer programming problems have variables: you need to give a length $n$ sequence of integers $(x[1], x[2], \ldots, x[n])$ that satisfies all the conditions below.
Quadratic integer programming problems have constraints: the sequence of integers you give needs to satisfy the following two types of constraints:
The quadratic integer programming problem has an objective function: you are given given $k-2$ weight parameters $v[2], v[3], \ldots , v[k-1]$. Let $c[i]$ be the number of elements in the sequence whose value is $i$, and $G$ be the number of pairs $1 \le i, j \le n$ such that $|p[i] - p[j]| \le 1$ (note that when $i \neq j$, $(i, j)$ and $(j, i)$ are not the same). The weight of a sequence $x[1], x[2], \ldots, x[n]$ is:
$$\displaystyle W(x[1], x[2], \ldots, x[n]) = 10^{6}G + \sum_{i = 2}^{k - 1} c[i] v[i]$$
Your sequence needs to maximize its weight while satisfying the above two constraints.
Quadratic integer programming problems do not necessarily require multiple queries, but we will give $q$ queries, each query giving different weight parameters $v[2], v[3], \ldots, v[k-1]$. For each query, you need find a sequence of maximum weight that satisfies the constraints. To reduce the output, you only need to output the weight of this sequence. The data guarantees that at least one sequence that satisfies the above conditions exists.
There are multiple sets of test data for this question. The first line contains a non-negative integer $C$ and a positive integer $T$, which represent the test case number and the number of data sets, respectively. $C = 0$ indicates that this set of data is a sample.
For each test case:
For each set of queries for each set of data, output a row of integers representing the maximum weight of the sequence.
Assume \sum q is the sum of q of all test data in a single test point. For all test points,
| Case | $T \leq$ | $k=$ | $\sum q \leq$ | Special Property |
|---|---|---|---|---|
| 1 | $10$ | $3$ | $200$ | None |
| 2 | $600$ | $3 \times 10^5$ | ||
| 3 | $10$ | $4$ | $200$ | |
| 4 | $600$ | $3 \times 10^5$ | ||
| 5 | $10$ | $5$ | $300$ | |
| 6 | $15$ | $500$ | ||
| 7 | $25$ | $750$ | ||
| 8 | $50$ | $1000$ | ||
| 9 | $80$ | $1500$ | ||
| 10 | $120$ | $2000$ | ||
| 11 | $200$ | $8000$ | A | |
| 12 | $400$ | $3 \times 10^4$ | ||
| 13 | $600$ | $2 \times 10^5$ | ||
| 14 | $200$ | $8000$ | B | |
| 15 | $400$ | $3 \times 10^4$ | ||
| 16 | $600$ | $2 \times 10^5$ | ||
| 17 | $120$ | $10^5$ | C | |
| 18 | $150$ | $2 \times 10^5$ | ||
| 19 | $180$ | $3 \times 10^5$ | ||
| 20 | $300$ | $5 \times 10^4$ | None | |
| 21 | $450$ | $10^5$ | ||
| 22 | $600$ | $3 \times 10^5$ |
Special property A: $m = 0$.
Special property B: $m \leq 10$, the sum of m of all test data in a single test point does not exceed $200$.
Special property C: The data is randomly generated. Specifically, when generating each set of test data in the test point, the parameters k, n, m, q and k non-negative integers p[0], $p[1], p[2], \ldots , p[k-1]$ are given to ensure that $p[k-1] \neq 0$, then the following rules are used to generate this data:
For $1 \leq i \leq n$, independent uniform random generation of $x, y \in [1, k]$, then $l[i] = min(x, y), r[i] = max(x, y)$;
Keep generating triples as follows until there are m triples:
$v[2], \ldots , v[k-1]$ of each set of queries are independently and uniformly generated randomly within $[0, 10^{12}]$.