背包

#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,Len;
long long F[2][100005];
struct node{
int c,f,v;
}E[100005];
bool cmp(node a,node b){
return a.f>b.f || (a.f==b.f && a.c>b.c);
}
int main(){
scanf("%d",&n);
for (int i=1; i<=n; i++) scanf("%d%d%d",&E[i].c,&E[i].f,&E[i].v);
for (int i=1; i<=n; i++) E[i].v=-E[i].v;
scanf("%d",&m);
for (int i=1; i<=m; i++) scanf("%d%d%d",&E[i+n].c,&E[i+n].f,&E[i+n].v);
for (int i=1; i<=m; i++) E[i+n].c=-E[i+n].c;
Len=n+m;
sort(E+1,E+Len+1,cmp);
int Max=0;
for (int i=0; i<Len; i++){
int tomax=Max;
if (E[i+1].c>0) tomax+=E[i+1].c;
for (int j=0; j<=Max; j++) F[(i+1)%2][j]=F[i%2][j];
for (int j=Max+1; j<=tomax; j++) F[(i+1)%2][j]=-1ll<<60;
for (int j=0; j<=Max; j++)
if (j+E[i+1].c>=0) F[(i+1)%2][j+E[i+1].c]=max(F[(i+1)%2][j+E[i+1].c],F[i%2][j]+E[i+1].v);
Max=tomax;
}
long long ans=0;
for (int i=0; i<=Max; i++) ans=max(ans,F[Len%2][i]);
printf("%lld\n",ans);
return 0;
}

  

BZOJ 5441: [Ceoi2018]Cloud computing的更多相关文章

  1. bzoj5441: [Ceoi2018]Cloud computing

    跟着大佬做题.. 这题也是有够神仙了.观察一下性质,c很小而f是一个限制条件(然而我并不会心态爆炸) %了一发,就是把电脑和订单一起做背包,订单的c视为负而电脑的v为负,f由大到小排序做背包 #inc ...

  2. what's cloud computing? IaaS

    Cloud computing has changed the ITC industry. Companies like Amazon, Google and Microsoft have built ...

  3. cloud theory is a failure? 分类: Cloud Computing 2013-12-26 06:52 269人阅读 评论(0) 收藏

    since LTE came out, with thin client cloud computing  and broadband communication clouding 不攻自破了.but ...

  4. 云计算中心网络资源分配-Faircloud: sharing the network in cloud computing

    网络资源同计算资源以及存储资源一样,是一种可被租户共享使用并提高利用率的资源.但是,不同租户的计算资源以及存储资源之间,有很强的隔离性,可以实现按需按比例分配的使用方式,但是网络资源却不可以. 主要原 ...

  5. How does java technology relate to cloud computing?

    Java Paas shootout   (@IBM developer) Cloud computing is always a hot topic around IT field today.Ho ...

  6. Cloud Computing Deployment Models

    Cloud computing can broadly be broken down into three main categories based on the deployment model. ...

  7. 学习笔记之Cloud computing

    Cloud computing - Wikipedia https://en.wikipedia.org/wiki/Cloud_computing

  8. Cloud Computing Causing Digital Business Transformation

    2015-04-13 Cloud Computing Causing Digital Business Transformation We hear all about the cloud, and  ...

  9. Cloud Computing

    More numbers, More power. We waste much more every day. Everything can be connectible through specia ...

随机推荐

  1. 在Unity3d中解析Lua脚本的方法

    由于近期项目中提出了热更新的需求,因此本周末在Lua的陪伴下度过.对Lua与Unity3d的搭配使用,仅仅达到了一个初窥门径的程度,记录一二于此.水平有限,欢迎批评指正. 网络上关于Lua脚本和Uni ...

  2. html5 新增表单控件和表单属性

    新的输入型控件 email:电子邮箱文本框,跟普通的没什么区别 当输入不是邮箱的时候,验证通不过 移动端的键盘会有变化         tel:电话号码 一般用于手机端,是一个键盘切换 url:网页的 ...

  3. H5的storage(sessionstorage&localStorage)简单存储删除

    众所周知,H5的storage有sessionstorage&localStorage,其中他们的共同特点是API相同 下面直接上代码,storage中的存储与删除: <!DOCTYPE ...

  4. Xiaocms 去版权

    Xiaocms 去版权 后台去版权: 1.  登录页面 修改文件:\admin\template\login.tpl.php 代码: <td width="190" rows ...

  5. 零基础逆向工程13_C语言07_指针01_反汇编

    1."带*类型"的特征探测 宽度 在同一个平台下,任何指针变量的尺寸都是一样的(都等于系统字长),如在32位平台中任何类型指针宽度都是32位. 声明 1.带有* 的变量类型的标准写 ...

  6. iOS-Swift相比Objective-C有哪些优缺点

    Swift,是苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Objective-C共同运行于Mac OS和iOS平台,用于搭建基于苹果平台的应用程序.它是一款易学易用的编程语言,而且 ...

  7. UVA1607 Gates 与非门电路 (二分)

    题意:给你一个按发生时间的序列,表示与非门电路的输入,一开始全部输入是x,现在要改成尽量少的x,实现相同的功能. 题解:电路功能只有4中0,1,x,非x.那么如果一开始x改变了,输出结果不变,那么说明 ...

  8. UVA 690 PipelineScheduling 位运算+dfs+剪枝

    一开始最容易想到间隔最多为n,但是结点还是太多了,需要优化. 预处理:预判一下并保存下一个可以放的位置距离之前的距离.这样可以减少很多判断. 最优化剪枝:如果当前长度+剩下没放的程序*最短间隔如果大于 ...

  9. cpp代码调试,调试扑克牌的代码

    #include <iostream> #include <vector> #include <algorithm> using namespace std; cl ...

  10. linux文本编辑器-VIM基本使用方法

    vim [OPTION]... FILE... +/PATTERN:打开文件后,直接让光标处于第一个被PATTERN匹配到的行的行首vim + file 直接打开file,光标在最后一行 三种主要模式 ...