No.1816 MUL-DIV Game
Problem Statement
$N$ integers $A_1,A_2,\dots A_N $ are written on a blackboard.
Alice and Bob play a game using the integers written on the blackboard. Alice goes first, and they alternately perform the following operations until exactly $1$ integer remains on the blackboard.
-
Alice's operation
- Choose $2$ integers written on the blackboard (call the chosen integers $x$ and $y$). Erase $x$ and $y$ from the blackboard, and write $x\cdot y$ on the blackboard.
-
Bob's operation
- Choose $2$ integers written on the blackboard (call the chosen integers $x$ and $y$). Erase $x$ and $y$ from the blackboard, and write $\lceil \frac{x}{y} \rceil$ on the blackboard.
Let $\mathrm{ans}$ be the only integer written on the blackboard at the end. Alice's goal is to maximize $\mathrm{ans}$, and Bob's goal is to minimize $\mathrm{ans}$.
Find $\mathrm{ans}$ when both players play optimally toward their goals.
Here, for a real number $a$, $\lceil a \rceil$ denotes the smallest integer greater than or equal to $a$.
Constraints
- All inputs are integers.
- $1 \le N\le 10^5$
- $1 \le A_i \le 10^9$
Input
$N$ $A_1$ $A_2$ $\dots$ $A_N$
Output
Output $\mathrm{ans}$.
Sample
Sample 1
Input
2 3 5
Output
15
Alice erases $3$ and $5$ and writes $3\cdot5 = 15$. Thus, $\mathrm{ans}=15$.
Sample 2
Input
3 1 1 1
Output
1
Alice erases $1$ and $1$ and writes $1\cdot1 = 1$. Bob erases $1$ and $1$ and writes $\lceil \frac{1}{1} \rceil=1$. Thus, $\mathrm{ans}=1$.
Sample 3
Input
1 10
Output
10
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nok0
riano