题目链接: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. R程序书写规范

    suppressMessages(library(xxx)) # 导入所需的R包 suppressMessages(library(xxx)) # 导入所需的R包 fucntion02 <- f ...

  2. git 学习网站

    GitBook  :https://git-scm.com/book/zh/v2 Git 教程 廖雪峰 :https://www.liaoxuefeng.com/wiki/89604348802960 ...

  3. Spring Security教程(四)

    在前面三个博客的例子中,登陆页面都是用的Spring Security自己提供的,这明显不符合实际开发场景,同时也没有退出和注销按钮,因此在每次测试的时候都要通过关闭浏览器来注销达到清除session ...

  4. Salesforce LWC学习(八) Look Up组件实现

    本篇参考https://www.salesforcelwc.in/2019/10/lookup-in-lwc.html,感谢前人种树. 我们做lightning的时候经常会遇到Look up 或者MD ...

  5. package.json中dependencies 与devDependencies 的区别

    首先,dependencies中安装的依赖是生产环境的依赖,即项目要运行所必须安装的包:devDependencies中安装的的依赖是开放环境的依赖,即在开发项目时需要安装的依赖. 其次,在安装依赖的 ...

  6. beego:限制接口访问频率

    package utils import ( "github.com/astaxie/beego" "github.com/astaxie/beego/context&q ...

  7. Sitecore 内容版本设计

    Sitecore内容变化的跟踪显着偏离既定规范.了解Sitecore中版本控制和工作流程的细节,该产品是对这些发布工具的回答. 在出版界,实时跟踪内容变化很常见,可能是由于Microsoft Word ...

  8. python面试导航

    python面试题库 python基础 等待更新中 函数 等待更新中 面向对象 等待更新中 高级编程 等待更新中 数据库 等待更新中 前端&django 等待更新中 crm 等待更新中 drf ...

  9. 【在 Nervos CKB 上做开发】Nervos CKB 脚本编程简介[4]:在 CKB 上实现 WebAssembly

    作者:Xuejie 原文链接:https://xuejie.space/2019_10_09_introduction_to_ckb_script_programming_wasm_on_ckb/ N ...

  10. VS web停止调试后关闭浏览器