zoukankan      html  css  js  c++  java
  • CF w1d1 B. Expansion coefficient of the array

    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.

    Input

    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).

    Output

    Print one non-negative integer — expansion coefficient of the array a1,a2,…,an.

    Note

    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.

    这么简单的一题想多了。。wa了3、4次,无语

    #include<iostream>
    using namespace std;
    int a[300005],minn,k=1e9+5;
    int main()
    {
    	int n;
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    		int len=max(i-1,n-i);
    		if(k>a[i]/len)k=a[i]/len;
    	}
    	cout<<k;
    	return 0;
    }
    
  • 相关阅读:
    adb 连接小米1S真机调试
    【Docker】容器中找不到vi命令
    【BIEE】导出数据报错
    【SPSS】软件介绍
    【Oracle】查询字段的长度、类型、精度、注释等信息
    【BIRT】使用rptlibrary设置统一数据源
    【Oracle】迁移含有BLOG类型的字段的表
    【Linux】war包的解压与压缩
    【docker】挂载web应用
    【Docker】安装tomcat并部署应用
  • 原文地址:https://www.cnblogs.com/LiangYC1021/p/12656594.html
Copyright © 2011-2022 走看看