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只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- WGS 全基因组测序数据分析
1. DNA测序技术 https://www.jianshu.com/p/6122cecec54a 2.FASTA和FASTQ文件格式 https://www.jianshu.com/p/50ff30 ...
- Java 并发系列之九:java 原子操作类Atomic(13个)
1. 原子更新基本类型类 2. 原子更新数组 3. 原子更新引用 4. 原子更新属性 5. txt java 原子操作类Atomic 概述 java.util.concurrent.atomic里的原 ...
- Prometheus 介绍
我们知道zabbix在监控界占有不可撼动的地位,功能强大.但是对容器监控显得力不从心.为解决监控容器的问题,引入了prometheus技术.prometheus号称是下一代监控.接下来的文章打算围绕p ...
- Python 3.X 练习集100题 05
用 *号输出字母 C的图案 方法1: print(" ***** ") print(" ** * ") print(" ** ") prin ...
- linux阿里云服务器更换镜像的方法
linux阿里云服务器更换镜像的方法 1 先进入硬盘创建快照 生成自定义镜像 ps:他可以在阿里云各个服务器上共享 再左侧镜像 点击去可以看到共享 直接进ecs 关闭服务器 重新初始化硬盘 然后主界面 ...
- 第九节:ASP.NET Core 中多环境的使用
一. 环境相关配置 1. 说明 ASP.NET Core 在应用启动时读取环境变量 ASPNETCORE_ENVIRONMENT, ASPNETCORE_ENVIRONMENT 可设置为任意值,但框架 ...
- Akka-CQRS(13)- SSL/TLS for gRPC and HTTPS:自签名证书产生和使用
到现在,我们已经完成了POS平台和前端的网络集成.不过,还是那句话:平台系统的网络安全是至关重要的.前一篇博客里我们尝试实现了gRPC ssl/tls网络连接,但测试时用的证书如何产生始终没有搞清楚. ...
- java数字前面补充0公共方法
- 常用Java API之Ramdom--用代码模拟猜数小游戏
常用Java API之Ramdom Ramdom类用来生成随机数字.使用起来也是三个步骤: 1.导包 import java.util.Random; 2.创建 Random r = new Rand ...
- win10下apache superset的使用
官方文档:http://superset.apache.org/ 一.环境准备 安装python3即3.4以上版本 二.python创建一个虚拟环境用来作为superset的容器 -pip3 inst ...