codeforce Round #379 (Div. 2)C(贪心)
来源:互联网 发布:深圳网络固定地址 编辑:程序博客网 时间:2024/05/22 09:39
题目链接
C. Anton and Making Potions
贪心,用魔法肯定比不要要好,所以遍历
复杂度
不过要注意的是数据有点大,还有就是注意边值数据,对于边值数据最好是在数组中设置哨兵。
代码
#include <cstdio>#include <cstring>#include <queue>#include<algorithm>#include<iostream>#include<cmath>#include<vector>#define INF 0x3f3f3f3f#define maxn 200009#define fi first#define se secondusing namespace std;typedef long long LL;typedef unsigned long long uLL;typedef pair<int,int> PI;LL n,m,k,x,s;LL ans;LL a[maxn],b[maxn],c[maxn],d[maxn];int main(){ //freopen("H:\\c++\\file\\stdin.txt","r",stdin); cin>>n>>m>>k>>x>>s; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); memset(d,0,sizeof(d)); a[0] = x; d[k+1] = (LL)3*1e9; for(int i=1 ; i<=m ; ++i)cin>>a[i]; for(int i=1; i<=m ; ++i)cin>>b[i]; for(int i=1 ; i<=k ; ++i)cin>>c[i]; for(int i=1 ; i<=k ; ++i)cin>>d[i]; ans = n*x; for(int i=0 ; i<=m ; ++i) { if(b[i]>s)continue; int p = upper_bound(d,d+k+1,s-b[i])-d; while(p>=0 && d[p]>s-b[i])p--; LL re = n-c[p]; if(re<0)ans =0; ans = min(ans,re*a[i]); } cout<<ans<<endl; return 0;}
0 0
- codeforce Round #379 (Div. 2)C(贪心)
- 【codeforce】Round #402 Div.2 C
- Codeforce Round #384 (Div 2) C
- CodeForce Round #186 Div.2
- 【CodeForce】Codeforces Round #140 (Div. 2) A B C
- 【CodeForce】Codeforces Round #142 (Div. 2) A B C
- Codeforce Round #438 C.Bus(贪心)
- Codeforces Round #311 (Div. 2) C 贪心
- Codeforces Round #363 (Div. 2)-C--贪心
- Codeforces Round #370 (Div. 2) C 贪心
- Codeforces Round #375 (Div. 2) C (贪心)
- Codeforces Round #377 (Div. 2) D. Exams && codeforce 732 D 详解(贪心+二分)
- codeforce round 247 div.2 B
- Codeforce Round #422(Div 2) A
- Codeforce Round #422(Div 2) B
- Codeforce Round #384(Div 2)A
- codeforce 176#div.2 C
- Codeforces Round #205 (Div. 2) / 353C Find Maximum (贪心)
- android 竖向的progress bar
- Xcode:[__NSCFNumber length]: unrecognized selector sent to instance崩溃解决
- MySQL导出数据库命令
- cocos2dx 3.13.1show_all适配时DEBUG_FPS位置与之前版本不同
- python ____opendirector类
- codeforce Round #379 (Div. 2)C(贪心)
- netstat -tna基本用法
- asp.net 导出到excel
- 关于For of
- 微信公众号开发之接收普通消息
- 最小二乘支持向量机——LSSVM
- 用来截取数据库某一列字段中的一部分 SUBSTR函数
- java中使用mongodb增查改删
- 微信web开发者工具