题目链接:http://abc063.contest.atcoder.jp/tasks/arc075_b

题解:直接二分答案然后再判断(a-b)来替代不足的。看代码比较好理解,水题。

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = 1e5 + 10;
ll num[M];
ll n , a , b;
bool cheak(ll x) {
ll cn = a - b;
ll gl = 0;
for(int i = 0 ; i < n ; i++) {
ll gg = num[i] - b * x;
if(gg <= 0) continue;
else {
gl += gg / cn;
gl += (gg % cn != 0);
if(gl > x) return false;
}
}
if(gl > x) return false;
return true;
}
int main() {
scanf("%lld%lld%lld" , &n , &a , &b);
for(int i = 0 ; i < n ; i++) {
scanf("%lld" , &num[i]);
}
ll l = 0 , r = 1e9;
ll ans = r;
while(l <= r) {
ll mid = (l + r) >> 1;
if(cheak(mid)) r = mid - 1 , ans = min(mid , ans);
else l = mid + 1;
}
printf("%lld\n" , ans);
return 0;
}

最新文章

  1. cinnamon桌面安装在其他目录下
  2. Atitit.iso格式蓝光&#160;BDMV&#160;结构说明
  3. 《Thinking in Java》十七章_容器深入研究_练习14(Page486)
  4. Linux下通过ioctl系统调用来获取和设置网络信息
  5. Unix时间戳 和 NSDate 的转换
  6. javascript google map circle radius_changed ,angularjs google map circle radius_changed
  7. DNA和纳米(Nano)Fusion技术的发展趋势
  8. 第四章——SQLServer2008-2012资源及性能监控(1)
  9. linux_常用压缩,解压缩命令
  10. VS XCOPY
  11. 在nagios中使用nrpe自定义脚本
  12. HDU - 1241 dfs or bfs [kuangbin带你飞]专题一
  13. echarts 折线图自定义颜色与修改legend颜色
  14. eclipse集成lombok
  15. 从文本中提取图片路径(java 解析富文本处理 img 标签)
  16. vi十六进制编辑
  17. Luogu5245 【模板】多项式快速幂(多项式exp)
  18. “必须执行Init_Clk函数,才能采集到二氧化碳接口485数据的问题”的解决
  19. Docker搭建PXC集群
  20. codeforces 475D

热门文章

  1. 基于TP5.1实用案例及教程
  2. 从无到满意offer,你需要知道的那些事
  3. S3 介绍
  4. css公共样式 | 标签元素初始化
  5. 算法与数据结构基础 - 二叉树(Binary Tree)
  6. AOSP 预置 APP
  7. linux安装MySQL后输入mysql显示 ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket
  8. mybatis的sql参数化查询
  9. 移动开发-UI设计
  10. Go-项目结构和代码组织