bzoj5441: [Ceoi2018]Cloud computing
跟着大佬做题。。
这题也是有够神仙了。观察一下性质,c很小而f是一个限制条件(然而我并不会心态爆炸)
%了一发,就是把电脑和订单一起做背包,订单的c视为负而电脑的v为负,f由大到小排序做背包
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL; struct node{int c,f;LL v;}a[];
bool cmp(node n1,node n2){return n1.f==n2.f?n1.c>n2.c:n1.f>n2.f;}
LL f[];
int main()
{
int n,m;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d%lld",&a[i].c,&a[i].f,&a[i].v);
a[i].v=-a[i].v;
}
scanf("%d",&m);
for(int i=n+;i<=n+m;i++)
{
scanf("%d%d%lld",&a[i].c,&a[i].f,&a[i].v);
a[i].c=-a[i].c;
}
n+=m;
sort(a+,a+n+,cmp); int maxp=;LL lin;
memset(f,-,sizeof(f));f[]=;
lin=f[];
for(int i=;i<=n;i++)
{
if(a[i].c>)
{
for(int j=maxp;j>=;j--)
if(f[j]!=lin)
{
f[j+a[i].c]=max(f[j+a[i].c],f[j]+a[i].v);
if(j+a[i].c>maxp)maxp=j+a[i].c;
}
}
else
{
for(int j=-a[i].c;j<=maxp;j++)
if(f[j]!=lin)
f[j+a[i].c]=max(f[j+a[i].c],f[j]+a[i].v);
}
} LL ans=;
for(int i=;i<=maxp;i++)ans=max(ans,f[i]);
printf("%lld\n",ans);
return ;
}
bzoj5441: [Ceoi2018]Cloud computing的更多相关文章
- BZOJ 5441: [Ceoi2018]Cloud computing
背包 #include<cstdio> #include<algorithm> using namespace std; int n,m,Len; long long F[2] ...
- what's cloud computing? IaaS
Cloud computing has changed the ITC industry. Companies like Amazon, Google and Microsoft have built ...
- 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 ...
- 云计算中心网络资源分配-Faircloud: sharing the network in cloud computing
网络资源同计算资源以及存储资源一样,是一种可被租户共享使用并提高利用率的资源.但是,不同租户的计算资源以及存储资源之间,有很强的隔离性,可以实现按需按比例分配的使用方式,但是网络资源却不可以. 主要原 ...
- 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 ...
- Cloud Computing Deployment Models
Cloud computing can broadly be broken down into three main categories based on the deployment model. ...
- 学习笔记之Cloud computing
Cloud computing - Wikipedia https://en.wikipedia.org/wiki/Cloud_computing
- Cloud Computing Causing Digital Business Transformation
2015-04-13 Cloud Computing Causing Digital Business Transformation We hear all about the cloud, and ...
- Cloud Computing
More numbers, More power. We waste much more every day. Everything can be connectible through specia ...
随机推荐
- java攻城狮之路--复习xml&dom_pull编程续
本章节我们要学习XML三种解析方式: 1.JAXP DOM 解析2.JAXP SAX 解析3.XML PULL 进行 STAX 解析 XML 技术主要企业应用1.存储和传输数据 2.作为框架的配置文件 ...
- C# 配置文件ini操作类
// [ DllImport ( "kernel32" ) ] //private static extern long WritePrivateProfileString ( s ...
- python PIL相关操作
项目中需要用python生成二维码,这里记录一下相关PIL相关操作. RGBA问题: 需要将图片A粘贴到图片B上,之前没有注意透明度问题,A的背景是透明的,粘贴到B上后,A的周围是黑的.后来才发现是P ...
- (转)Arcgis for JS之Cluster聚类分析的实现
http://blog.csdn.net/gisshixisheng/article/details/40711075 在做项目的时候,碰见了这样一个问题:给地图上标注点对象,数据是从数据库来的,包含 ...
- js的三种对象
JS中,可以将对象分为“内部对象”.“宿主对象”和“自定义对象”三种. 1,内部对象 js中的内部对象包括Array.Boolean.Date.Function.Global.Math.Number. ...
- Laravel实用小功能
Laravel实用小功能 1.控制访问次数 laravel5.2的新特性,通过中间件设置throttle根据IP控制访问次数 原理:通过回传三个响应头X-RateLimit-Limit,X-RateL ...
- 1. Python中的基本数据类型、运算、变量
本文利用的是Python 3.x版本,建议学习3.x版本 Python中的基本数据类型.运算.变量 1. 基本数据类型 1.1 整数 py可以处理任意大小的整数,例如123,1234567891324 ...
- 第六节:web爬虫之urllib(二)
二.urllib.request.Request(url, data=None, headers={}, origin_req_host=None, unverifiable=False, metho ...
- copy the content of a file muliptle times and save as ordered files:
input: transient.case outputs: transient_1.case, transient_2.case,...transient_101.case ********** n ...
- 洛谷 2387 NOI2014魔法森林 LCT
[题解] 我们先把边按照$a$值从小到大排序,并按照这个顺序加边. 如果当前要加入的边连接的两点$u$与$v$已经是连通的,那么直接加入这条边就会出现环.这时我们需要删除这个环中$b$值最大的边.因此 ...