No.5018 Let's Make a Best-seller Book
タグ : / 解いたユーザー数 33
作問者 :
e869120
/ テスター :
trineutron
Problem Statement
There are $N$ bookstores in Japan, numbered from $1$ to $N$.
Each bookstore has a value called book popularity, and initially the popularity is $0$ at every bookstore.
In addition, each bookstore has a fixed value called book sellability. The sellability of bookstore $i$ is $D_i$ $(0.5 \leqq D_i < 1.5)$, but initially nobody knows this value.
Now, Yuki Publishing has just published a book titled "How to Become a Red Coder in 3 Months".
To sell the book, the publisher can take one of the following actions at the beginning of each week.
Initially, the publisher has $200$ × 10,000 yen.
-
1. Ship books
- Choose a sequence $L = (L_1, L_2, \cdots, L_N)$ and ship $L_i$ copies of the book to bookstore $i$.
- The cost is $500$ yen per $1$ copy, that is, $500(L_1 + L_2 + \cdots + L_N)$ yen in total.
-
2. Run an advertisement
- Choose an integer $x$ between $1$ and $5$, inclusive, and run a level $x$ advertisement.
- Then, the popularity increases by $x$ at every bookstore.
- The cost is $500000 \times 2^{x-1}$ yen.
Let $P_i$ be the popularity and $R_i$ be the remaining stock of bookstore $i$ immediately after the publisher has finished the above action. The number of copies sold at bookstore $i$ in this week is given by the following formula.
Here, $\text{rand}(0.75, 1.25)$ is a random number following the uniform distribution on values at least $0.75$ and less than $1.25$.
$$
\lfloor \min(R_i, R_i^{0.5} \times 1.05^{P_i} \times D_i \times \text{rand}(0.75, 1.25)) \rfloor
$$
For each $1$ copy sold, the publisher receives $1000$ yen at the end of the week.
If the weekly sales at bookstore $i$ are at least $0.3R_i$ copies, the popularity at this bookstore increases by $1$ at the end of the week.
On the other hand, if the weekly sales at bookstore $i$ are less than $0.1R_i$ copies, the popularity at this bookstore decreases by $1$ at the end of the week.
However, if the stock at the beginning of the week (after the publisher's action) is zero, the popularity does not change.
Implement a strategy for the publisher to sell as many copies as possible by $T$ weeks later.
Note that the popularity can increase only up to $+60$ at most and can decrease only down to $-60$ at least. Also, no books are returned.
Also, note that before week $1$ starts, the stock is zero at every bookstore.
Constraints
- $T=52$
- $N=10$
- $0.5 \leqq D_i < 1.5$ (note that these are hidden values not given in the input)
Input and Output
This is an interactive problem. Note that the input and output format differs from that of ordinary problems.
First, you must receive input in the following format. Here, the initial money is $\text{Money}=2000000$.
$T$ $N$ $\text{Money}$
Then, repeat the following (a) and (b), in this order, $T$ times.
(a) Output the publisher's action.
To ship $L_i$ copies of the book to bookstore $i$ $(1 \leqq i \leqq N)$, output in the following format.
Here, letting $\text{Money}$ be the money at the beginning of the week, $0 \leqq L_i$ and $500(L_1 + L_2 + \cdots + L_N) \leqq \text{Money}$ must be satisfied.
$1$ $L_1$ $L_2$ $\cdots$ $L_N$
To run a level $x$ advertisement, output in the following format.
Here, letting $\text{Money}$ be the money at the beginning of the week, $1 \leqq x \leqq 5$ and $500000 \times 2^{x-1} \leqq \text{Money}$ must be satisfied.
$2$ $x$
(b) Receive data such as the number of copies sold.
Let $\text{Money}$ be the money at the end of the week, $S_i$ be the number of copies sold at bookstore $i$ in this week, and $P_i$ and $R_i$ be the popularity and the remaining stock, respectively, of bookstore $i$ at the end of the week. You receive input in the following format. (Note that the values of $S_i, P_i, R_i$ are those after the popularity update has finished.)
$\text{Money}$
$S_1$ $S_2$ $\cdots$ $S_N$
$P_1$ $P_2$ $\cdots$ $P_N$
$R_1$ $R_2$ $\cdots$ $R_N$
Important: Flush standard output after every 1 output. Otherwise, you may get TLE.
Scoring
Letting $\text{Result}$ be the number of copies sold, your score is $\lceil \text{Result}/100 \rceil$ points.
However, if your output is invalid, the verdict is WA. Invalid output means any of the following.
- The output does not follow the output format.
- You took an action for which you did not have enough money.
- When ordering books for the bookstores, your output did not satisfy $0 \leqq L_i$.
- When running an advertisement, your output did not satisfy $1 \leqq x \leqq 5$.
If you produce invalid output at some point, you will receive a single line containing $-1$ in step (b) of the Input and Output section, so terminate your program immediately.
If you do not terminate your program, the verdict may be another error such as TLE or RE.
There are $100$ test cases in total, and the score of a submission is the sum of the scores over all test cases.
The final ranking is determined by the highest score obtained during the contest, and no system test is performed after the contest ends.
Since the number of test cases is $100$, note that the total score is approximately the average number of copies sold.
Sample Code / Hints
Beginners in heuristics are encouraged to read this section.
First, for those who are not used to interactive problems, sample code in C++ and Python is provided below.
This program is based on the approach of shipping $\lfloor \text{Money}/(500N) \rfloor$ copies to each bookstore, where $\text{Money}$ is the money at the beginning of the week.
Also note that, since the "remaining stock" is given as input in this problem, you do not necessarily have to compute the stock yourself.
Test Case Generation / Generator
Note that this section is not essential for understanding the problem.
Test cases are generated in the following way.
- For each $i$ $(1 \leqq i \leqq N)$, the value of $D_i$ is a random number following the uniform distribution on values at least $0.5$ and less than $1.5$.
- In addition, for each $(t, i)$ $(1 \leqq t \leqq T, 1 \leqq i \leqq N)$, a random number $Z_{t, i}$ following the uniform distribution on values at least $0.75$ and less than $1.25$ is fixed (this value differs for each test case), and the value of $\text{rand}(0.75, 1.25)$ at bookstore $i$ in week $t$ is $Z_{t, i}$. For $\text{rand}(0.75, 1.25)$, see the Problem Statement section.
The test case generator can be downloaded here.
It takes a seed value as input and outputs a test case, so feel free to use it with the code test feature or similar.
Sample 1
Note that, unlike the constraints, $T=2$ in this sample.
| Input to the program | Output of the program |
|---|---|
| 2 10 2000000 | |
| 1 30 30 30 30 30 30 30 30 30 30 | |
| 1903000 5 3 9 2 6 5 5 3 8 7 0 0 1 -1 0 0 0 0 0 0 25 27 21 28 24 25 25 27 22 23 |
|
| 2 2 | |
| 946000 5 3 6 3 7 3 4 3 6 3 2 2 3 1 2 2 2 2 2 2 20 24 15 25 17 22 21 24 16 20 |
The number of copies sold is $96$, so the final score is $\lceil 96/100 \rceil = 1$ point.
Note that the following happens at the end of week $1$.
- At bookstore $3$, at least $30\%$ of the stock was sold, so the popularity of bookstore $3$ increased by $1$.
- At bookstore $4$, less than $10\%$ of the stock was sold, so the popularity of bookstore $4$ decreased by $1$.
Sample 2
Note that this sample shows an example of incorrect output.
| Input to the program | Output of the program |
|---|---|
| 2 10 2000000 | |
| 1 200000 200000 200000 200000 200000 200000 200000 200000 200000 200000 | |
| -1 |
Note that when the user produces invalid output, a single line containing -1 is received.
The test case itself is the same as in Sample 1.
Samples Satisfying the Constraints (100 cases)
100 test cases satisfying the constraints can be downloaded here. (seed = 1 to 100)
The input is in the order $T, N, D_i, Z_{t, i}$. Note that $D_i$ and $Z_{t, i}$ are not given in the actual input.
For $Z_{t, i}$, see the Test Case Generation section.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。