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