Codeforces Round #379 (Div. 2) C. Anton and Making Potions
来源:互联网 发布:阿里云os5.1系统root 编辑:程序博客网 时间:2024/05/01 01:55
Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to preparen potions.
Anton has a special kettle, that can prepare one potions in x seconds. Also, he knows spells of two types that can faster the process of preparing potions.
- Spells of this type speed up the preparation time of one potion. There are m spells of this type, the i-th of them costsbi manapoints and changes the preparation time of each potion toai instead ofx.
- Spells of this type immediately prepare some number of potions. There are k such spells, the i-th of them costsdi manapoints and instantly createci potions.
Anton can use no more than one spell of the first type andno more than one spell of the second type, and the total number of manapoints spent should not exceeds. Consider that all spells are used instantly and right before Anton starts to prepare potions.
Anton wants to get to the next level as fast as possible, so he is interested in the minimum number of time he needs to spent in order to prepare at leastn potions.
The first line of the input contains three integers n,m,k (1 ≤ n ≤ 2·109, 1 ≤ m, k ≤ 2·105) — the number of potions, Anton has to make, the number of spells of the first type and the number of spells of the second type.
The second line of the input contains two integers x ands (2 ≤ x ≤ 2·109, 1 ≤ s ≤ 2·109) — the initial number of seconds required to prepare one potion and the number of manapoints Anton can use.
The third line contains m integers ai (1 ≤ ai < x) — the number of seconds it will take to prepare one potion if thei-th spell of the first type is used.
The fourth line contains m integers bi (1 ≤ bi ≤ 2·109) — the number of manapoints to use thei-th spell of the first type.
There are k integers ci (1 ≤ ci ≤ n) in the fifth line — the number of potions that will be immediately created if thei-th spell of the second type is used. It's guaranteed thatci arenot decreasing, i.e.ci ≤ cj ifi < j.
The sixth line contains k integers di (1 ≤ di ≤ 2·109) — the number of manapoints required to use thei-th spell of the second type. It's guaranteed thatdi arenot decreasing, i.e.di ≤ dj ifi < j.
Print one integer — the minimum time one has to spent in order to prepare n potions.
20 3 210 992 4 320 10 404 1510 80
20
20 3 210 992 4 3200 100 4004 15100 800
200
思路:由于第二种药剂的单调性,我们可以枚举第一种药剂然后二分第二种药剂的选择(mp的选择)。这样就可以做到在nlogn的时间内解决。
注意考虑边界情况。
其实就算第二种药剂没有单调性,也可以强行转换成有单调性的,毕竟一种药剂只能使用一次。
代码链接:
#include <bits/stdc++.h>using namespace std;const int maxn=1e6+5;int secondmp[maxn],secondans[maxn];int firstmp[maxn],firstans[maxn];int main(){ int n,m,k,x,s; scanf("%d %d %d",&n,&m,&k); scanf("%d %d",&x,&s); for(int i=1;i <= m;i++ ) { scanf("%d",&firstans[i]); } for(int i=1;i <= m;i++ ) { scanf("%d",&firstmp[i]); } for(int i=1;i <= k;i++ ) { scanf("%d",&secondans[i]); } for(int i=1;i <= k;i++ ) { scanf("%d",&secondmp[i]); } long long ans=1LL*n*x; firstans[0]=x; for(int i=0;i<=m;i++) { if(s-firstmp[i]<0) continue; int now=upper_bound(secondmp,secondmp+k+1,s-firstmp[i])-secondmp; now--; long long nowans=1LL*(n-secondans[now])*firstans[i]; ans=min(ans,nowans); } cout<<ans<<endl; return 0;}
- Codeforces Round #379 (Div. 2) C. Anton and Making Potions
- Codeforces Round #379 (Div. 2) C. Anton and Making Potions
- Codeforces Round #379 (Div. 2) C. Anton and Making Potions//734C
- Codeforces Round #379 (Div. 2) -- C. Anton and Making Potions(简单的分类讨论 + 二分)
- Codeforces Round #379 (Div. 2)C. Anton and Making Potions(二分)
- Codeforces Round #379 (Div. 2) C. Anton and Making Potions(枚举+二分)
- Codeforces Round #379 (Div. 2) C. Anton and Making Potions —— 二分
- Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分
- codeforces 734C Anton and Making Potions
- Codeforces 734C. Anton and Making Potions
- CodeForces 734C - Anton and Making Potions
- 【13.77%】【codeforces 734C】Anton and Making Potions
- Codeforces 734C Anton and Making Potions(二分)
- CodeForces 734C Anton and Making Potions 【二分】【贪心】
- Codeforces-734C-Anton and Making Potions(枚举+二分)
- 【Codeforces 734 C Anton and Making Potions 】+ 思维
- codeforces 734 C. Anton and Making Potions (二分 STL)
- CodeForces 734 C.Anton and Making Potions(二分)
- 【网易云课堂直播预告】直播中视频编码实践经验总结
- NPOI读取excel2003和excel2007格式
- SQL优化技巧
- 16 tensorBorad 可视化练习
- 十大经典排序算法(一)
- Codeforces Round #379 (Div. 2) C. Anton and Making Potions
- test
- LeNet模型简介
- Java NIO中Selector类源码
- 不能相邻的字符对
- 64. Minimum Path Sum
- 39. Combination Sum
- 216. Combination Sum III
- Linux下的一些问题收集及解决方法(一)