背包

#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. asp.net重启web应用程序域

    我把加载到static静态变量中了,是在数据库中存的,这样每次改了一下必须要重启一下web应用程序,每次去iis操作太麻烦了,于是找的了这个重启的办法,一句话代码: System.Web.HttpRu ...

  2. Wrinkles should merely indicate where smiles have been.

    Wrinkles should merely indicate where smiles have been. 皱纹应该只是微笑留下的印记.

  3. Android方法数methods超过65536

    当Android App中的方法数超过65535时,如果往下兼容到低版本设备时,就会报编译错误: Cannot fit requested classes in a single dex file. ...

  4. 【extjs6学习笔记】1.6 初始:本地化

    app.json中修改

  5. javaScript的注释、变量和基本数据类型

    上一级写了javaScript是用来操作文档对象元素的,这一次带大家看看javaScriput的注释.变量和基本数据类型. 1.注释:注释是什么呢?注释其实就是阻止浏览器解析某一行或者多行代码或描述的 ...

  6. HTML之基本语法(链接标签、路径的介绍和使用)

    一.链接标签 语法:<a href="目标地址">这个标签上展示的内容</a> 作用:可以实现在当前页面跳转到新页面的操作 属性 1.target这个属性可 ...

  7. Python静态方法 类方法

    通常情况下,类中函数中定义的所有函数,,都是对象的绑定方法,除此之外,还有专门的静态方法和类方法,这两个是专门给类使用的,但是对象非要调用也是不会报错的. 对象在调用的时候会把自己传递给self,也就 ...

  8. CPP-STL:vector中的size和capacity

    在vector中与size()和capacity() 相对应的有两个函数: resize(size_type)和reserve(size_type). Size指目前容器中实际有多少元素,对应的res ...

  9. SQLServer死锁

    死锁的四个必要条件:互斥条件(Mutual exclusion):资源不能被共享,只能由一个进程使用.请求与保持条件(Hold and wait):已经得到资源的进程可以再次申请新的资源.非剥夺条件( ...

  10. php的字符转换 & php登入注册界面设计以及源码 & 分离公共部分

    我们在编写的时候总是会出现乱码 https://www.cnblogs.com/mafeng/p/5827215.html php登入注册界面设计以及源码 https://blog.csdn.net/ ...