背包

#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. Column 'xxx' in field list is ambiguous

    一 其实看一下ambiguous的翻译就好了 一开始我觉得是含糊什么的,后来找了下才知道应该是双关... 二 所以翻译过来就是 : 列'XX'在字段列表中双关 其实就是两张表有相同的字段,但是使用时, ...

  2. 洛谷 P1969 积木大赛

    题目描述 春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是hi. 在搭建开始之前,没有任何积木(可以看成 ...

  3. $.ajax同步/异步(async:false/true)

    虽然说ajax用来执行异步请求的比较多,但有时还是存在需要同步执行的情况的. 比如:我需要通过ajax取执行请求以返回一个值,这个值在ajax后面是需要使用到的,这时就不能用异步请求了.这时候就需要使 ...

  4. IT部门域事件与业务分析

    IT event--->system--->IT dept |--------------->IT dept |--------------->system 域事件分类: 直接 ...

  5. Python+selenium之带unittest的脚本分析

    from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.c ...

  6. HDU 1864 最大报销额(01背包,烂题)

    题意:被坑惨,单项不能超过600,其实是一张发票上A类/B类/C类的总和分别不能超过600. 思路:此题的数据很烂.用贪心也能过,用01背包也可以.都测试不出到底那些是错的. #include < ...

  7. windows 10 无法使用内置管理员账户打开应用的解决方案

    步骤 运行regedit.msc: 依次找到:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ ...

  8. BZOJ 1137: [POI2009]Wsp 岛屿 半平面交

    1137: [POI2009]Wsp 岛屿 Time Limit: 10 Sec  Memory Limit: 162 MBSec  Special JudgeSubmit: 165  Solved: ...

  9. Iterator中的next()

    DBExchangeMoney类: 1 package com.ch.test15; import java.sql.DriverManager; import java.sql.ResultSet; ...

  10. python_107_ __metaclass__ 元类

    类默认是由 type 类实例化产生,type类中如何实现的创建类?类又是如何创建对象? 答:类中有一个属性 __metaclass__,其用来表示该类由 谁 来实例化创建,所以,我们可以为 __met ...