Codeforces Round #350 (Div. 2) D2. Magic Powder - 2
题目链接:
http://codeforces.com/contest/670/problem/D2
题解:
二分答案。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std; const int maxn = + ;
const int INF = 2e9;
typedef __int64 LL; int n, k;
int x[maxn], y[maxn]; bool solve(int num, LL kk) {
for (int i = ; i < n; i++) {
if ((LL)x[i] * num>y[i]) {
kk -= ((LL)x[i] * num - y[i]);
}
if (kk < ) return false;
}
return true;
} int main() {
scanf("%d%d", &n, &k);
for (int i = ; i < n; i++) scanf("%d", x + i);
for (int i = ; i < n; i++) scanf("%d", y + i);
int l = , r = INF + ;
while (l < r - ) {
int mid = l + (r - l) / ;
if (solve(mid, k)) l = mid;
else r = mid;
}
printf("%d\n", l);
return ;
}
Codeforces Round #350 (Div. 2) D2. Magic Powder - 2的更多相关文章
- Codeforces Round #350 (Div. 2)_D2 - Magic Powder - 2
D2. Magic Powder - 2 time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #350 (Div. 2) D1. Magic Powder - 1 二分
D1. Magic Powder - 1 题目连接: http://www.codeforces.com/contest/670/problem/D1 Description This problem ...
- Codeforces Round #350 (Div. 2) D2 二分
五一期间和然然打的团队赛..那时候用然然的号打一场掉一场...七出四..D1是个数据规模较小的题 写了一个暴力过了 面对数据如此大的D2无可奈何 现在回来看 一下子就知道解法了 二分就可以 二分能做多 ...
- Codeforces Round #350 (Div. 2) A B C D1 D2 水题【D2 【二分+枚举】好题】
A. Holidays 题意:一个星球 五天工作,两天休息.给你一个1e6的数字n,问你最少和最多休息几天.思路:我居然写成模拟题QAQ. #include<bits/stdc++.h> ...
- Codeforces Round #350 (Div. 2)A,B,C,D1
A. Holidays time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Codeforces Round #527 (Div. 3) D2. Great Vova Wall (Version 2) 【思维】
传送门:http://codeforces.com/contest/1092/problem/D2 D2. Great Vova Wall (Version 2) time limit per tes ...
- Codeforces Round #350 (Div. 2) D1
D1. Magic Powder - 1 time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #335 (Div. 2) A. Magic Spheres 水题
A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...
- Codeforces Round #443 (Div. 1) D. Magic Breeding 位运算
D. Magic Breeding link http://codeforces.com/contest/878/problem/D description Nikita and Sasha play ...
随机推荐
- shell下添加计划性任务
*/1 * * * * /bin/sh /tmp/hello.sh ###每1分钟执行以下/tmp下的hello.sh脚本 service crond restart 重启任务计划 * 12 * ...
- SqlServer存储过程
新上线的车管系统,今天要给User添加权限,才发现这个后台加权限简直how to play .. 比如有人申请合肥的关务权限: 1.SITE 是合肥 2.ORG 有B81,P81,S81,M81等 3 ...
- webservice安全性之 SoapHeader自定义身份验证
相信很多开发者都用过WebService来实现程序的面向服务,本文主要介绍WebService的身份识别实现方式,当然本文会提供一个不是很完善的例子,权当抱砖引玉了. 首先我们来介绍webservic ...
- Eclipse之Failed to load the JNI shared library”……\jvm.dll”的解决方案
问题描述:java环境变量配置完全正确,但是运行eclipse时提示:Failed to load the JNI shared library " xxx\jva.dll" 原因 ...
- 【C++】快排
假设要排序的数据类型为int int main() { qsort(a,len,sizeof(int),cmp); //qsort(数组的起始位置,排序个数,类型大小,比较函数); } int cmp ...
- python2.7爬取豆瓣电影top250并写入到TXT,Excel,MySQL数据库
python2.7爬取豆瓣电影top250并分别写入到TXT,Excel,MySQL数据库 1.任务 爬取豆瓣电影top250 以txt文件保存 以Excel文档保存 将数据录入数据库 2.分析 电影 ...
- [转]Openwrt的Inittab
转来一篇关于启动的文章,特意收藏.http://see.sl088.com/wiki/Inittab 文件位于/etc/inittab编辑方法vi /etc/inittab初始内容::sysinit: ...
- Python os模块常用部分功能
os.sep 可以取代操作系统特定的路径分割符. os.name字符串指示你正在使用的平台.比如对于Windows,它是'nt',而对于Linux/Unix用户,它是'posix'. os.getcw ...
- LPHW-积累-ex1-6
Learn Python The Hard Way ex0 介绍了各个操作系统下python的安装:强调了初学者最好使用简单的编辑器,不要使用IDE环境 ex1 使用 print 输出简单的字符串 ...
- C高级 服务器内核分析和构建 (一)
引言 最经看cloud wind 的 skynet服务器设计. 觉得特别精妙. 想来个专题先剖析其通信层服务器内核 的设计原理. 最后再优化.本文是这个小专题的第一部分, 重点会讲解对于不同平台通信基 ...