CodeForces 670D Magic Powder
二分。
二分一下答案,然后验证一下。
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<stack> #include<iostream> using namespace std; typedef long long LL; const double pi=acos(-1.0),eps=1e-6; void File() {freopen("D:\\in.txt","r",stdin);freopen("D:\\out.txt","w",stdout); } template <class T> inline void read(T &x) {char c=getchar(); x=0;while(!isdigit(c)) c=getchar();while(isdigit(c)) {x=x*10+c-'0'; c=getchar();} }const int maxn=100010; LL k,a[maxn],b[maxn]; int n;bool check(LL x) {LL sum=0;for(int i=1;i<=n;i++){if(a[i]*x<=b[i]) continue;sum=sum+a[i]*x-b[i];if(sum>k) return 0;}if(sum<=k) return 1;return 0; }int main() {scanf("%d%lld",&n,&k);for(int i=1;i<=n;i++) scanf("%lld",&a[i]);for(int i=1;i<=n;i++) scanf("%lld",&b[i]);LL L=0,R=3e9,ans;while(L<=R){LL mid=(L+R)/2;if(check(mid)) L=mid+1,ans=mid;else R=mid-1;}printf("%lld\n",ans);return 0; }
转载于:https://www.cnblogs.com/zufezzt/p/5899578.html
CodeForces 670D Magic Powder相关推荐
- codeforces 670D1 Magic Powder - 1
题目链接:http://codeforces.com/problemset/problem/670/D1 题目:Magic Powder - 1 time limit per test 1 secon ...
- CodeForces 670D2 Magic Powder - 2
Description The term of this problem is the same as the previous one, the only exception - increased ...
- CodeForces 670D2 Magic Powder - 2(二分+贪心)
http://codeforces.com/contest/670/problem/D2 简单的二分,二分所有可以做的饼干数,然后遍历就可以啦 #include <iostream> #i ...
- 【CodeForces - 670D1 】Magic Powder - 1 (模拟 或 枚举 或二分优化)
题干: This problem is given in two versions that differ only by constraints. If you can solve this pro ...
- Magic Powder - 2
https://codeforces.com/contest/670/problem/D2 The term of this problem is the same as the previous o ...
- Magic Powder - 2 (CF 670_D)
http://codeforces.com/problemset/problem/670/D2 The term of this problem is the same as the previous ...
- codeforce之Magic Powder
题目: The term of this problem is the same as the previous one, the only exception - increased restric ...
- Magic Powder - 1,2
问题 This problem is given in two versions that differ only by constraints. If you can solve this prob ...
- Magic Powder - 2 CodeForces - 670D2(二分答案)
先贴一篇关于二分边界问题的博客,看来自己还是对二分边界的理解不够深入 题目:今天我们要来造房子.造这个房子需要n种原料,每造一个房子需要第i种原料ai个.现在你有第i种原料bi个.此外,你还有一种特殊 ...
最新文章
- 如何使用Java中的UTC或GMT获取当前日期和时间?
- python字符串find函数-python常见字符串处理函数与用法汇总
- kib,mib和mb,kb的区别
- 1077篇!ICCV2019接收结果公布,你中了吗?(附7篇论文链接,含Oral)
- 内附PPT下载 | 阿里云资深技术专家 陈长城:一站式数据管理DMS及最新解决方案解读
- File类判断和获取功能
- 解决 IntelliJ IDEA 安装后界面消失,再次打开后界面不动
- 315曝光不良奸商 对企业不能罚酒三杯
- e盘是否具有读写权限_轻松搭建MySQL主从复制、读写分离(双机热备)
- 2021-07-07IF神经元模型
- centos6.2安装jdk7
- NLP︱高级词向量表达(二)——FastText(简述、学习笔记)
- mapbox 加载json数据 和数据中颜色 和高度 并根据数值加载颜色
- DBC2000是什么?DBC2000数据库文件超详细讲解
- 将html页面转成word(亲测可用)
- 华为网络篇 华为路由器的初始化配置-05
- 数据分析三大神器之一:Numpy
- 网络(韩志刚版笔记)
- 写给自己——瞎写瞎画坑规(自己挖坑自己填啊!!)
- MIT Technology Review 2022年“全球十大突破性技术”解读
热门文章
- 5月11日云栖精选夜读丨清华大学成功卫冕ASC18世界超算总决赛冠军,黑马上海科大斩获AI大奖
- 旅游消费券发放,驴妈妈造福旅游爱好者
- 小说阅读器 免费源码 高颜值 功能齐全
- SDIO_WiFi驱动学习之SDIO架构介绍及源码分析
- 社群经济与组织社群化 (2)
- 58 mysql 军规_58 到家 MySQL 军规升级版
- 常用flash引擎和框架
- 利用IDL输出影像快视图、拇指图
- Error:Flash Download failed - Could not load file ****.axf
- 信息技术用计算机绘画,童心笔下挥洒的那份真——信息技术组电脑绘画成果