题目链接:http://codeforces.com/problemset/problem/734/C

题目大意:要制作n个药,初始制作一个药的时间为x,魔力值为s,有两类咒语,
第一类周瑜有m种,每种咒语使制作一个药的时间变成a[i],花费b[i]的魔力,
第二类咒语有k种,每种咒语瞬间产生c[i]个药,花费d[i]的魔力,c[i]和d[i]都是不递减的,
求最短时间内产生n个药的时间。
解题思路:
因为c[i]和d[i]都是不降的,所以可以枚举a[i],然后二分查找花费小于t-b[i]的第二类咒语。
注意这里要用upper_bound()而不能用lower_bound(),比如
10 12
82 82
前者会找到12,而后者会找到10。

代码:

 #include<bits/stdc++.h>
#define lc(a) (a<<1)
#define rc(a) (a<<1|1)
#define MID(a,b) ((a+b)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define clr(arr,val) memset(arr,val,sizeof(arr))
#define _for(i,start,end) for(int i=start;i<=end;i++)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long LL;
const int N=2e5+;
const int INF=0x3f3f3f3f;
const double eps=1e-; LL n,m,k,x,s;
LL a[N],b[N],c[N],d[N]; int main(){
FAST_IO;
cin>>n>>m>>k>>x>>s;
for(int i=;i<=m;i++){
cin>>a[i];
}
for(int i=;i<=m;i++){
cin>>b[i];
}
for(int i=;i<=k;i++){
cin>>c[i];
}
for(int i=;i<=k;i++){
cin>>d[i];
} LL ans=x*n; //初始化为不用魔法所需时间
a[]=x; for(int i=;i<=m;i++){
//魔力值不够
if(b[i]>s) continue;
LL t=s-b[i];
int pos=upper_bound(d+,d++k,t)-d;
pos--;
ans=min(ans,a[i]*(n-c[pos]));
}
cout<<ans<<endl;
return ;
}

Codeforces 734C Anton and Making Potions(枚举+二分)的更多相关文章

  1. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分

    C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is p ...

  2. Codeforces 734C. Anton and Making Potions(二分)

    Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass ...

  3. Codeforces gym101612 L.Little Difference(枚举+二分)

    传送:http://codeforces.com/gym/101612 题意:给定一个数n(<=1e18),将n分解为若干个数的成绩.要求这些数两两之间的差值不能大于1. 分析: 若n==2^k ...

  4. Codeforces H. Prime Gift(折半枚举二分)

    题目描述: Prime Gift time limit per test 3.5 seconds memory limit per test 256 megabytes input standard ...

  5. C. Anton and Making Potions 贪心 + 二分

    http://codeforces.com/contest/734/problem/C 因为有两种操作,那么可以这样考虑, 1.都不执行,就是开始的答案是n * x 2.先执行第一个操作,然后就会得到 ...

  6. Codeforces Round #379 (Div. 2) C. Anton and Making Potions —— 二分

    题目链接:http://codeforces.com/contest/734/problem/C C. Anton and Making Potions time limit per test 4 s ...

  7. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 二分

    C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input ...

  8. [二分] Codefoces Anton and Making Potions

    Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input sta ...

  9. CodeForce-734C Anton and Making Potions(贪心+二分)

    CodeForce-734C Anton and Making Potions  C. Anton and Making Potions time limit per test 4 seconds m ...

随机推荐

  1. [SDOI2009] HH去散步 (矩阵乘法)

    link $solution:$ 将边化为点后重新建矩阵,跑$T-1$幂即可(因为跑的是新边). 最后直接找与$x,y$所相连的边即可. #include<iostream> #inclu ...

  2. MySQL 第五篇:索引原理与慢查询优化

    一 介绍 为何要有索引? 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,在生产环境中,我们遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,因此对查询语句 ...

  3. php 通过链接生成二维码,扫码支付用到

    $(".good_info").on('click',function () { var id = $(this).data('id'); var string='http://q ...

  4. npm 5.4.2 更新后就不能用了

    今天刚,npm run dev 就出现更新提示,没多想就更了, 更新用了49S,下来npm 的所以命令包一个semer的插件 ... 最后下载新node 8.5覆盖安装, 就解决了, node 8.5 ...

  5. 转:实现OC与JS的简易交互

    oc-->js stringByEvaluatingJavaScriptFromString,其参数是一NSString 字符串内容是js代码(这又可以是一个js函数.一句js代码或他们的组合) ...

  6. 科学计算三维可视化---TVTK入门(数据加载)

    一:数据加载 大多数可视化应用的数据并非是在TVTK库中构建的,很多都是通过接口读取外部数据文件 (一)使用vtkSTLReader来读取外部文件 .stl 文件是在计算机图形应用系统中,用于表示三角 ...

  7. bzoj千题计划116:bzoj1025: [SCOI2009]游戏

    http://www.lydsy.com/JudgeOnline/problem.php?id=1025 题目转化: 将n分为任意段,设每段的长度分别为x1,x2,…… 求lcm(xi)的个数 有一个 ...

  8. 高维数据降维 国家自然科学基金项目 2009-2013 NSFC Dimensionality Reduction

    2013 基于数据降维和压缩感知的图像哈希理论与方法 唐振军 广西师范大学 多元时间序列数据挖掘中的特征表示和相似性度量方法研究 李海林 华侨大学       基于标签和多特征融合的图像语义空间学习技 ...

  9. SpringCloud(六) Hystrix入门

    前提 一个可用的Eureka注册中心(文中以之前博客中双节点注册中心,不重要) 一个连接到这个注册中心的服务提供者 快速入门 项目搭建 搭建一个新maven项目,artifactid为Ribbon-c ...

  10. 2.批处理内部命令之REM 和::

    REM为注释命令,一般用来给程序加上注解,该命令后的内容不被执行,但能回显. 另外, :: 也可以起到rem 的注释作用, 而且更简洁有效; 但有两点需要注意: 1. 任何以冒号:开头的字符行, 在批 ...