背包

#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. 关于锚点页内链接跳转出现问题(不响应,没有反应)的解决方法(ZT)

    我们知道,利用锚点可以实现页面链接跳转,也可以实现同一页面内的跳转功能. 例如:<a href="somepage.htm>某页面链接</a>  可以跳转链接到som ...

  2. 零基础逆向工程23_PE结构07_重定位表_IAT表(待补充)

    重定位表 待补充 IAT表 待补充

  3. java项目定时任务实现

    首先配置spring-context.xml文件 在xmlns 下加如下代码 xmlns:task="http://www.springframework.org/schema/task&q ...

  4. static 关键字用法

    static a=0; 就是把a初始化为0:初始值为0而已 即使a是局部变量,每次进入此变量所在的函数,a值还是保持上次赋值: 在中断里建议在局部变量前加上static,以确保此变量值的寿命

  5. C++string类型转换为C数组

    #include <string> #include <iostream> using namespace std; int main(){ string str; str.a ...

  6. 链接服务器"(null)"的 OLE DB 访问接口 "SQLNCLI10" 返回了消息 "Cannot start more transactions on this session."

    开发同事反馈一个SQL Server存储过程执行的时候,报"链接服务器"(null)"的 OLE DB 访问接口 "SQLNCLI10" 返回了消息 ...

  7. python+selenium之中类/函数/模块的简单介绍和方法调用

    # coding=utf-8 class ClassA (object): string1 = "这是一个字符串." def instancefunc(self): print ( ...

  8. 洛谷 P3143 [USACO16OPEN]钻石收藏家Diamond Collector

    题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining diamonds in her s ...

  9. js菜鸟备忘

    1.图片切换 function changeImage() { var img = document.getElementById("myImg"); ")) img.s ...

  10. ASP.NET 验证控件报错:WebForms UnobtrusiveValidationMode 需要“jquery”ScriptResourceMapping。

    在Visual Studio 2012中添加并使用验证控件时,可能会遇到如下的错误: WebForms UnobtrusiveValidationMode 需要“jquery”ScriptResour ...