A12643 | Expansion coefficient of the array
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Let's call an array of non-negative integers $a_1, a_2, \ldots, a_n$ a $k$ -extension for some non-negative integer $k$ if for all possible pairs of indices $1 \leq i, j \leq n$ the inequality $k \cdot |i - j| \leq min(a_i, a_j)$ is satisfied. The expansion coefficient of the array $a$ is the maximal integer $k$ such that the array $a$ is a $k$ -extension. Any array is a 0-expansion, so the expansion coefficient always exists.
You are given an array of non-negative integers $a_1, a_2, \ldots, a_n$ . Find its expansion coefficient.
You are given an array of non-negative integers $a_1, a_2, \ldots, a_n$ . Find its expansion coefficient.
输入格式
The first line contains one positive integer $n$ — the number of elements in the array $a$ ( $2 \leq n \leq 300\,000$ ). The next line contains $n$ non-negative integers $a_1, a_2, \ldots, a_n$ , separated by spaces ( $0 \leq a_i \leq 10^9$ ).
输出格式
Print one non-negative integer — expansion coefficient of the array $a_1, a_2, \ldots, a_n$ .
输入输出样例
输入 #1
4 6 4 5 5
输出 #1
1
输入 #2
3 0 1 2
输出 #2
0
输入 #3
4 821 500 479 717
输出 #3
239
In the first test, the expansion coefficient of the array $[6, 4, 5, 5]$ is equal to $1$ because $|i-j| \leq min(a_i, a_j)$ , because all elements of the array satisfy $a_i \geq 3$ . On the other hand, this array isn't a $2$ -extension, because $6 = 2 \cdot |1 - 4| \leq min(a_1, a_4) = 5$ is false.
In the second test, the expansion coefficient of the array $[0, 1, 2]$ is equal to $0$ because this array is not a $1$ -extension, but it is $0$ -extension.
In the second test, the expansion coefficient of the array $[0, 1, 2]$ is equal to $0$ because this array is not a $1$ -extension, but it is $0$ -extension.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted