CodeForces - 1159B
题目链接: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的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- 网络测试工具netperf(转)
http://pangyi.github.io/blog/20141210/wang-luo-ce-shi-gong-ju-netperf/ 网络测试工具netperf 2014年12月10日 一般我 ...
- 2018-2019-2 20165313 《网络对抗技术》 Exp 8 Web基础
一.实践要求: (1).Web前端HTML(0.5分) 能正常安装.启停Apache.理解HTML,理解表单,理解GET与POST方法,编写一个含有表单的HTML. (2).Web前端javascip ...
- Python(三)对装饰器的理解
装饰器是 Python 的一个重要部分,也是比较难理解和使用好的部分.下面对装饰器做一下简单整理 1. 前言 装饰器实际上是应用了设计模式里,装饰器模式的思想: 在不概念原有结构的情况下,添加新的功能 ...
- MVC发布出现:未能将文件bin\xxx.xml 复制到 obj\Release\PackageTmp\bin\xxx.xml,未能找到文件
之前写的项目好好的,也可以发布,然后今天要发布MVC项目,一直报错,报下面这个错误 莫名其妙搞了好久,没搜到合理的解决方案,结果就只能瞎搞了. 突然想起了,我前几天犯贱把项目根目录下的bin文件夹和o ...
- Swagger2.9.2进入API界面报NumberFormatException异常
[转载请注明]: 原文出处:https://www.cnblogs.com/jstarseven/p/11778377.html 作者:jstarseven 码字挺辛苦的..... ...
- volatile 和 内存屏障
接下来看看volatile是如何解决上面两个问题的: 被volatile修饰的变量在编译成字节码文件时会多个lock指令,该指令在执行过程中会生成相应的内存屏障,以此来解决可见性跟重排序的问题. 内存 ...
- select列表遍历和触发事件
1.以下两种都是jquery获取select列表被选中的value.var strText=$("#select_id").find("option:selected&q ...
- 根据jdk1.8源码整理而得,java集合体系(继承、实现关系)图解,超清晰,一看就懂,方便记忆
一.前言 1. 该关系图是本人根据JDK1.8 源码整理所得,只整理了常用的.常见的集合,并非全部. 2. 整理逻辑: Collection接口下有两个子接口:List 和 Set 接口. Map是独 ...
- Antd中,Select 中value设值,导致placeholder不生效解决方法
<Select key="sm2" placeholder="姓名" showSearch={true} allowClear={true} showAr ...
- [转帖]Centos7防火墙配置rich-rule实现IP端口限制访问
Centos7防火墙配置rich-rule实现IP端口限制访问 2019-02-18 18:05:35 sunny05296 阅读数 2143 收藏 更多 分类专栏: Linux 版权声明:本文 ...