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,…,ana_1, a_2, \ldots, a_n a kk-extension for some non-negative integer kk if for all possible pairs of indices 1≤i,j≤n1 \leq i, j \leq n the inequality k⋅∣i−j∣≤min(ai,aj)k \cdot |i - j| \leq min(a_i, a_j) is satisfied. The expansion coefficient of the array aa is the maximal integer kk such that the array aa is a kk-extension. Any array is a 0-expansion, so the expansion coefficient always exists.

You are given an array of non-negative integers a1,a2,…,ana_1, a_2, \ldots, a_n. Find its expansion coefficient.

我们称一个非负整数数组 a1,a2,…,ana_1, a_2, \ldots, a_n 为某个非负整数 kk 的 kk-扩展数组(kk-extension),当且仅当对所有可能的下标对 1≤i,j≤n1 \leq i, j \leq n,均满足不等式

k⋅∣i−j∣≤min⁡(ai,aj).k \cdot |i - j| \leq \min(a_i, a_j).

数组 aa 的扩展系数(expansion coefficient)定义为使得 aa 成为 kk-扩展数组的最大整数 kk。由于任意数组都是 00-扩展数组,因此扩展系数恒存在。

现给你一个非负整数数组 a1,a2,…,ana_1, a_2, \ldots, a_n,请找出它的扩展系数。

输入格式

The first line contains one positive integer nn — the number of elements in the array aa (2≤n≤300 0002 \leq n \leq 300\,000). The next line contains nn non-negative integers a1,a2,…,ana_1, a_2, \ldots, a_n, separated by spaces (0≤ai≤1090 \leq a_i \leq 10^9).

第一行包含一个正整数 nn —— 数组 aa 的元素个数(2≤n≤300 0002 \leq n \leq 300\,000)。
下一行包含 nn 个非负整数 a1,a2,…,ana_1, a_2, \ldots, a_n,以空格分隔(0≤ai≤1090 \leq a_i \leq 10^9)。

输出格式

Print one non-negative integer — expansion coefficient of the array a1,a2,…,ana_1, a_2, \ldots, a_n.

输出一个非负整数——数组 a1,a2,…,ana_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][6, 4, 5, 5] is equal to 11 because ∣i−j∣≤min(ai,aj)|i-j| \leq min(a_i, a_j), because all elements of the array satisfy ai≥3a_i \geq 3. On the other hand, this array isn't a 22-extension, because 6=2⋅∣1−4∣≤min(a1,a4)=56 = 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][0, 1, 2] is equal to 00 because this array is not a 11-extension, but it is 00-extension.

在第一个测试中,数组 [6,4,5,5][6, 4, 5, 5] 的扩张系数等于 11,因为对所有下标 i,ji,j 均满足 ∣i−j∣≤min⁡(ai,aj)|i-j| \leq \min(a_i, a_j),这是由于该数组所有元素均满足 ai≥3a_i \geq 3。另一方面,该数组不是 22-扩张的,因为不等式 6=2⋅∣1−4∣≤min⁡(a1,a4)=56 = 2 \cdot |1 - 4| \leq \min(a_1, a_4) = 5 不成立。

在第二个测试中,数组 [0,1,2][0, 1, 2] 的扩张系数等于 00,因为该数组不是 11-扩张的,但它是 00-扩张的。

输入解题思路,AI测评打分。不知道怎么写?

首页