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只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- css特效之旋转音乐播放器
本次需要用到的知识点有: transform setInerval 怎么添加背景音乐我会在下一篇介绍 https://www.cnblogs.com/zouwangblog/p/11138734.ht ...
- HttpClient代理IP及设置连接读取超时
1.不废话,上代码: public static void main(String[] args) throws Exception { CloseableHttpClient httpClient ...
- c# .net 使用Confluent.Kafka针对kafka进行生产和消费
首先说明一点,像Confluent.Kafka这种开源的组件,三天两头的更新.在搜索引擎搜索到的结果往往用不了,浪费时间.建议以后遇到类似的情况直接看官网给的Demo. 因为搜索引擎搜到的文章,作者基 ...
- 【神经网络与深度学习】chainer边运行边定义的方法使构建深度学习网络变的灵活简单
Chainer是一个专门为高效研究和开发深度学习算法而设计的开源框架. 这篇博文会通过一些例子简要地介绍一下Chainer,同时把它与其他一些框架做比较,比如Caffe.Theano.Torch和Te ...
- cad.net 定义lisp
首先是传参型lisp的定义: (addLine (getpoint)) //定义lisp传入参数的例子 //复制到命令栏运行: (addLine (getpoint)) [LispFunction(& ...
- CentOS中使用FIO测试磁盘IO性能
$ yum install fio 0x02 命令 随机读: $ fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randread - ...
- redux本来是同步的为什么它能执行异步代码(chunk)实现原理是什么 中间件的实现原理是什么
我们用redux执行同步的时候,都是先发起一个dispatch(actionCreator()) 1.先在actionCreator()中生成一个action对象. 2.由dispatch方法将act ...
- 微软官方关于 Windows To Go 的常见问题
Windows To Go:常见问题 2016/04/01 本文内容 什么是 Windows To Go? Windows To Go 是否依赖虚拟化? 哪些人员应该使用 Windows To Go? ...
- 项目启动redis连接报错
问题解决: 1)打开端口6379(修改iptabels文件) 2)关闭防火墙.(可能linux防火墙作用,限制了端口的出入) 3)修改redis.conf文件,将 bind 127.0.0.1这一行注 ...
- Linux 常用文件描述
Linux 常用文件描述 /etc/issue 本地登陆显示的信息,本地登录前 /etc/issue.net 网络登陆显示的信息,登录后显示,需要由sshd配置 /etc/motd 常用于通告信息,如 ...