【题解】

  二分答案。r要设好,不能随便设置为max(s,len),不然check的时候会爆long long

  

 #include<cstdio>
#include<algorithm>
#define rg register
#define N 200010
#define LL long long
using namespace std;
LL n,s,len,mx,h[N],a[N],l,r,mid;
inline LL read(){
LL k=; char c=getchar();
while(c<''||c>'')c=getchar();
while(''<=c&&c<='')k=k*+c-'',c=getchar();
return k;
}
inline bool check(){
LL cnt=;
for(rg int i=;i<=n;i++)
if(1LL*h[i]+a[i]*mid>=len){
cnt+=1LL*h[i]+a[i]*mid;
if(cnt>=s) return ;
}
return ;
}
int main(){
n=read(); s=read(); len=read();
for(rg int i=;i<=n;i++) h[i]=read();
for(rg int i=;i<=n;i++) a[i]=read(),mx=max(mx,a[i]);
l=-; r=max(s,len)/mx+;
while(l+<r){
mid=(l+r)>>;
if(check()) r=mid; else l=mid;
}
printf("%lld\n",r);
return ;
}

BZOJ 5106 [CodePlus2017]汀博尔的更多相关文章

  1. bzoj5106: [CodePlus2017]汀博尔(二分答案)

    5106: [CodePlus2017]汀博尔 题目:传送门 题解: 百题纪念!!! 原谅一下第一百题刷了到水题... 直接二分月份然后判断(注意上界大小) 代码: #include<cstdi ...

  2. bzoj5106 [CodePlus2017]汀博尔 二分

    [CodePlus2017]汀博尔 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 202  Solved: 75[Submit][Status][Di ...

  3. [CodePlus2017]汀博尔

    Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 158  Solved: 61[Submit][Status][Discuss] Description ...

  4. BZOJ5106: [CodePlus2017]汀博尔

    [传送门:BZOJ5106] 简要题意: 给出n棵树,初始高度为h[i],每棵树每个月长高a[i] 现有一个客户,需要至少s长的总木材,而且每次截取的木材必须是一整颗树而且高度大于等于L 求出最少的月 ...

  5. [LOJ 6249]「CodePlus 2017 11 月赛」汀博尔

    Description 有 n 棵树,初始时每棵树的高度为 H_i,第 i 棵树每月都会长高 A_i.现在有个木料长度总量为 S 的订单,客户要求每块木料的长度不能小于 L,而且木料必须是整棵树(即不 ...

  6. Code+ B 汀博尔【二分答案】

    时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld 题目描述 有 n 棵树,初始时每棵树的高度为 Hi,第 ...

  7. BZOJ.5110.[CodePlus2017]Yazid 的新生舞会(线段树/树状数组/分治)

    LOJ BZOJ 洛谷 又来发良心题解啦 \(Description\) 给定一个序列\(A_i\).求有多少个子区间,满足该区间众数出现次数大于区间长度的一半. \(n\leq5\times10^5 ...

  8. 翻译:《What can I hold you with?》—— 博尔赫斯《英文诗两首》之一。

    What can I hold you with? 我拿什么才能留住你? I offer you lean streets, desperate sunsets, the moon of the ja ...

  9. 全国城市三级联动 html+js

    全国城市三级联动,没有css,所以屏幕的自适应必须自己想办法,手机端慎用(最好不要用,因为有些我也说不出的展示问题). html页面 <!DOCTYPE html> <html> ...

随机推荐

  1. hdu1814 Peaceful Commission——2-SAT

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1814 第一次的2-SAT,推荐博客:https://blog.csdn.net/jarjingx/arti ...

  2. Spark 决策树--分类模型

    package Spark_MLlib import org.apache.spark.ml.Pipeline import org.apache.spark.ml.classification.{D ...

  3. Vue Router过渡动效

    <router-view> 是基本的动态组件,所以我们可以用 <transition> 组件给它添加一些过渡效果: <transition> <router- ...

  4. 分享几篇有关react-native的博客

    http://segmentfault.com/a/1190000002646155 http://facebook.github.io/react-native/docs/native-module ...

  5. POJ 2773 欧几里得

    思路: 若a和b互素的话,则b*t+a和b一定互素 用周期性做就好了 //By SiriusRen #include <cstdio> using namespace std; ],m,k ...

  6. 最大流增广路(KM算法) HDOJ 1853 Cyclic Tour

    题目传送门 /* KM: 相比HDOJ_1533,多了重边的处理,还有完美匹配的判定方法 */ #include <cstdio> #include <cmath> #incl ...

  7. Android 性能优化(12)网络优化( 8)Monitoring the Battery Level and Charging State

    Monitoring the Battery Level and Charging State PreviousNext This lesson teaches you to Determine th ...

  8. 理解 Java 构造函数不可以继承

    参考来源:http://www.52bowen.com/a/2604620.html

  9. [ TJOI 2010 ] 打扫房间

    \(\\\) Description 给出一个\(N\times M\) 的网格,一些格子是污点,求是否能用多个封闭的环路覆盖所有不是污点的格点. 封闭的环路覆盖的含义是,每条路径都必须是一个环,且每 ...

  10. 《CSS世界》学习笔记(一)

    <CSS世界>,张鑫旭著,人民邮电出版社,2017年12月第一版. 1.P9二维码链接文章的demo值得一看,可以实现有关“某些区域颜色始终保持一致”的效果. P9二维码所链接文章的一个d ...