問題一覧 > 通常問題

No.2221 Set X

レベル : / AI推定難易度 : 2100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 62
作問者 : stoq / テスター : Shirotsume misty1999
お気に入りにしたユーザー ProblemId : 8146 / 自分の提出
問題文最終更新日: 2023-02-04 10:52:00
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 377 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。