题目链接:https://vjudge.net/problem/CodeForces-1159B

题目意思:任选选两个元素,分别为a[i],a[j]。

问 都满足K*| i -  j | <= min(a[i],a[j]),K的最大值是多少。

K <= min(a[i],a[j] / |  i - j |。

其实就是K要多小才能满足“任选选两个元素,分别为a[i],a[j]。还满足不等式”。

我们可以枚举每个元素,记当前元素下标为index,那么我们只需要选出 max(index - 开头,结尾 - index),然后选出min(a[index],a[离index最远的元素]),计算不等式。

那么我们总会得出那个K至少多小。


 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std; typedef long long LL;
#define inf (1LL << 30)
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--) const int N = ;
int arr[N]; int main(){ ios::sync_with_stdio(false);
cin.tie(); int n;
cin >> n;
rep(i,,n) cin >> arr[i]; int ans = inf;
rep(i,,n){ int l = i - ;
int r = n - i; if(l > r){
ans = min(ans, min(arr[],arr[i])/l);
}
else if(l < r){
ans = min(ans, min(arr[n],arr[i])/r);
}
else if(l == r){
ans = min(ans, min(arr[],arr[i])/l);
ans = min(ans, min(arr[n],arr[i])/r);
}
} cout << ans << endl; getchar();getchar();
return ;
}

CodeForces - 1159B的更多相关文章

  1. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  2. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  3. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  4. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  5. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  6. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  7. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  8. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

  9. CodeForces - 148D Bag of mice

    http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...

随机推荐

  1. git filter-branch之后撤销到原来状态

    起因 因为要拆分仓库,所以按照原来的操作拆分,拆分完成后发现有问题,所以准备还原重新拆分. 注意 git filter-branch之后,不可以做其他额外操作 运行git filter-branch之 ...

  2. 几句话总结一个算法之Policy Gradients

    强化学习与监督学习的区别在于,监督学习的每条样本都有一个独立的label,而强化学习的奖励(label)是有延后性,往往需要等这个回合结束才知道输赢 Policy Gradients(PG)计算某个状 ...

  3. 解析XML数据

    在 Java 程序中读取 XML 文件的过程称为解析 XML 解析 XML 文件的方式 1) DOM 解析 (java 官方提供) 2) SAX 解析(java 官方提供) 3) JDOM 解析(第三 ...

  4. CloseableHttpClient方式配置代理服务器访问外网

    小编最近在负责银行内部项目.其中有模块需要访问天眼查API接口,但由于公司全部内网,所以需要配置代理服务器才可以访问外网接口. 又到了激动人心的上码时刻! public void Connect(Ht ...

  5. Hyper-V虚拟机安装Ubuntu,启动的时候会出现:Please remove the installation medium,then press ENTER

    Hyper-V虚拟机安装Ubuntu成功以后,重启的时候页面会一直卡在下面,并报Please remove the installation medium,then press ENTER,这是因为启 ...

  6. [转帖]linux find -regex 使用正则表达式

    linux find -regex 使用正则表达式 https://www.cnblogs.com/jiangzhaowei/p/5451173.html find之强大毋庸置疑,此处只是带领大家一窥 ...

  7. eclipse的debug模式的F5,F6按键失灵

    在使用eclipse Mars.1 Release (4.5.1)开发过程中,发现debug模式下的快捷键无法使用,全部失效了.秉持坚决自己解决绝不求人的态度我艰苦的在度娘上寻求解决办法,有的说是快捷 ...

  8. C#简单构架之EF进行读写分离+多数据库Mysql/SqlServer

    http://www.php361.com/index.php?c=index&a=view&id=3857 不建议用,太重的框架EF,仅仅参考一下别人的思路就好. [导读]最近因为项 ...

  9. prometheus被OOM杀死

    参考https://www-01.ibm.com/support/docview.wss?uid=ibm10882172 提升内存配置 2.5版本后新增--query.max-samples 这个参数 ...

  10. Mycat分布式数据库架构解决方案--Mycat实现数据库分表

    echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.--这才是真正的堪称强大!!! 准备工 ...