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教程(七)使用JDOM修改XML文件内容
JDOM提供了非常灵活的方式操作XML文件,使用JDOM非常简单而且代码简洁可读性强.前面我们学习了如何使用JDOM解析XML文件,本节介绍如何使用JDOM修改XML文件内容. 在这个教程中,我们准备 ...
- StackOverflowError&OutOfMemoryError区别
在Java虚拟机规范中,针对内存分配规定两种异常状况,即StackOverflowError和OutOfMemoryError. StackOverflowError:当线程请求的内存大小大于所配置的 ...
- Android视频截图
本文介绍如何获取视频中某个时间点的数据 调用以下方法即可,特别注意,在获取图片时的参数单位为微秒,不是毫秒 如果错用了毫秒会一直获取第一帧的画面 /** * 获取某个时间点的帧图片 * * @para ...
- seam remote 返回的map结构
map结构的数据,js接收到的结构是elements下面的一个 [ {key:***,value:***}, {key:***,value:***} ] 这样子的集合,需要经过下面代码的转换才能重新变 ...
- CAD插入jpg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- 学习csv
1.csv文件读取,csv文件是常用的数据存储格式之一,我们使用Python模块来处理csv文件,这是一个天气信息表 import csv from matplotlib import pyplot ...
- HDU-4055 Number String 动态规划 巧妙的转移
题目链接:https://cn.vjudge.net/problem/HDU-4055 题意 给一个序列相邻元素各个上升下降情况('I'上升'D'下降'?'随便),问有几种满足的排列. 例:ID 答: ...
- VMware Workstation搭建Linux操作系统
1.单击“创建新的虚拟机”选项,并在弹出的“新建虚拟机向导”界面中选择“自定义”单选按钮,然后单击“下一步”. 新建虚拟机向导 2.选择虚拟机硬件兼容性,是否兼容之前旧的版本. 兼容性选择 3.选中“ ...
- Problem 63
Problem 63 https://projecteuler.net/problem=63 Powerful digit counts The 5-digit number, 16807=75, i ...
- Ubuntu | Flask + Gunicorn + Nginx 部署服务器环境
现在我们手里有一个准备发布的项目,那么如何将他上传到你的服务器,并让外网访问呢? 前提: 1. 安装了Python环境 apt-get install python-dev 2. 安装Flask pi ...