No.2221 Set X
タグ : / 解いたユーザー数 62
作問者 :
stoq
/ テスター :
Problem Statement
There is a sequence $A=(A_1,A_2,\dots,A_N)\ (A_1 < A_2 < \cdots < A_N)$ of length $N$.
For a positive integer $X$, define $$f(X) := (X+1) \times \left| \left\{ \left \lfloor \frac{A_1}{X} \right \rfloor , \left \lfloor \frac{A_2}{X} \right \rfloor, \dots, \left \lfloor \frac{A_N}{X} \right \rfloor \right\} \right|$$ . In other words, $f(X)$ is the product of $X+1$ and the number of distinct values among $\displaystyle \left \lfloor \frac{A_1}{X} \right \rfloor , \left \lfloor \frac{A_2}{X} \right \rfloor, \dots, \left \lfloor \frac{A_N}{X} \right \rfloor$.
Find the minimum value of $f(X)$ and the smallest $X$ that achieves this minimum value.
Input
$N$ $A_1$ $A_2$ $\dots$ $A_N$
- All inputs are integers.
- $1 \leq N \leq 10^5$
- $0 \leq A_1 < A_2 < \cdots < A_N \leq 10^9$
Output
Let $X_{\min}$ be the smallest $X$ that minimizes $f(X)$. Output in the following format.
$X_{\min}$
$f(X_{\min})$
Sample
Sample 1
Input
4 0 1 2 3
Output
4 5
$f(4) = (4+1) \times \left| \left\{ 0 \right\} \right| = 5 \times 1 = 5$.
$f(X)$ cannot be made smaller than this, and $f(X) > 5$ when $X < 4$, so $X=4$ and $f(X) = 5$ is the answer.
Sample 2
Input
6 3 4 5 6 7 8
Output
3 8
$f(3) = (3+1) \times \left| \left\{ 1,2 \right\} \right| = 4 \times 2 = 8$.
Sample 3
Input
8 0 1 2 6 7 9 10 11
Output
3 12
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。