問題一覧 > 通常問題

No.3073 Fraction Median

レベル : / AI推定難易度 : 1250 / 実行時間制限 : 1ケース 2.500秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 66
作問者 : 👑 AngrySadEight / テスター : 👑 qand 👑 hamamu
お気に入りにしたユーザー ProblemId : 12079 / 自分の提出
問題文最終更新日: 2025-03-20 02:04:14
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 461 (順位表) の他の問題:

Problem Statement

You are given $N$ positive integers $A_1, A_2, \dots, A_N$.

Consider choosing a pair of distinct integers $(i, j)$ satisfying $1 \leq i, j \leq N$. There are $N(N - 1)$ ways to make this choice. Considering $\dfrac{A_i}{A_j}$ for each of them, find the $\dfrac{N(N-1)}{2}$-th smallest value.

The answer can be expressed as $\dfrac{x}{y}$ using coprime positive integers $x, y$. Output these $x, y$.

Constraints

  • All input values are integers
  • $2 \leq N \leq 1.5 \times 10^6$
  • $1 \leq A_i \leq 10^9$

Input

The input is given from standard input in the following format.

$N$
$A_1$ $A_2$ $\dots$ $A_N$

Since the input can be large, using a fast input method is recommended.

Output

When the answer is expressed as $\dfrac{x}{y}$ using coprime positive integers $x, y$, output $x, y$ in this order, separated by a space.

Sample

Sample 1
Input
4
1 3 5 6
Output
5 6

Listing the $6$ smallest values of $\dfrac{A_i}{A_j}$ in ascending order gives $\dfrac{1}{6}, \dfrac{1}{5}, \dfrac{1}{3}, \dfrac{3}{6}, \dfrac{3}{5}, \dfrac{5}{6}$.

Therefore, the $6$-th smallest value of $\dfrac{A_i}{A_j}$ is $\dfrac{5}{6}$, so output $5, 6$ in this order, separated by a space.

Sample 2
Input
5
10 10 10 10 10
Output
1 1

All values of $\dfrac{A_i}{A_j}$ are $1$, so output 1 1.

Note that $x, y$ must be coprime. Therefore, an output such as 10 10, for example, will be judged as incorrect.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。