CF1159B.Expansion coefficient of the array
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call an array of non-negative integers a1,a2,…,an a k-extension for some non-negative integer k if for all possible pairs of indices 1≤i,j≤n the inequality k⋅∣i−j∣≤min(ai,aj) 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 a1,a2,…,an. Find its expansion coefficient.
我们称一个非负整数数组 a1,a2,…,an 为某个非负整数 k 的 k-扩展数组(k-extension),当且仅当对所有可能的下标对 1≤i,j≤n,均满足不等式
k⋅∣i−j∣≤min(ai,aj).
数组 a 的扩展系数(expansion coefficient)定义为使得 a 成为 k-扩展数组的最大整数 k。由于任意数组都是 0-扩展数组,因此扩展系数恒存在。
现给你一个非负整数数组 a1,a2,…,an,请找出它的扩展系数。
输入格式
The first line contains one positive integer n — the number of elements in the array a (2≤n≤300000). The next line contains n non-negative integers a1,a2,…,an, separated by spaces (0≤ai≤109).
第一行包含一个正整数 n —— 数组 a 的元素个数(2≤n≤300000)。
下一行包含 n 个非负整数 a1,a2,…,an,以空格分隔(0≤ai≤109)。
输出格式
Print one non-negative integer — expansion coefficient of the array a1,a2,…,an.
输出一个非负整数——数组 a1,a2,…,an 的展开系数。
输入输出样例
输入#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∣≤min(ai,aj), because all elements of the array satisfy ai≥3. On the other hand, this array isn't a 2-extension, because 6=2⋅∣1−4∣≤min(a1,a4)=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.
在第一个测试中,数组 [6,4,5,5] 的扩张系数等于 1,因为对所有下标 i,j 均满足 ∣i−j∣≤min(ai,aj),这是由于该数组所有元素均满足 ai≥3。另一方面,该数组不是 2-扩张的,因为不等式 6=2⋅∣1−4∣≤min(a1,a4)=5 不成立。
在第二个测试中,数组 [0,1,2] 的扩张系数等于 0,因为该数组不是 1-扩张的,但它是 0-扩张的。
输入解题思路,AI测评打分。不知道怎么写?