跟着大佬做题。。

这题也是有够神仙了。观察一下性质,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的更多相关文章

  1. BZOJ 5441: [Ceoi2018]Cloud computing

    背包 #include<cstdio> #include<algorithm> using namespace std; int n,m,Len; long long F[2] ...

  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. VC窗口类的销毁-是否需要delete

    Windows窗口如果使用new的方法添加之后,在父窗口析构的时候,有些需要delete有些却不需要delete.这个的确有点坑,由于c++的实现,对于每个自己new的对象,我都会delete删除它, ...

  2. 高级Java知识

    高级Java知识(JVM.字节码.内存模型) 内存=方法区+栈空间+堆+程序计数器 栈(stack)包括虚拟机栈(VM stack)和本地方法栈(native method stack). 方法区(m ...

  3. Linux下清空文件的常用方法

    1. 本人用的最多,感觉也是最方便的: > filename.log   2. : > filename.log 3. cat /dev/null > filename.log

  4. LVS部分调度算法的适应场景分析

    1.轮叫调度算法(RR)假设所有服务器处理性能均相同,不管服务器的当前连接数和响应速度.该算法相对简单,不适用于服务器组中处理性能不一的情况,而且当请求服务时间变化比较大时,轮叫调度算法容易导致服务器 ...

  5. js弹开页面并调用方法

    每次重新写一个功能的时候,都能发现以前写的并不太好,都可以改进,奇怪的是我还是我,为什么曾经的我就想不起来要这么写,比如下面两段代码 历史代码: if (infoTablePage != null) ...

  6. Python虚拟环境和requirements.txt文件的使用

    参考: https://www.centos.bz/2018/05/centos-7-4-%E5%AE%89%E8%A3%85python3%E5%8F%8A%E8%99%9A%E6%8B%9F%E7 ...

  7. UGUI世界坐标转换为UI本地坐标(游戏Hud的实现)

    实现世界坐标的原理是: 世界坐标和UGUI的坐标分属两个坐标系,他们之间是无法进行转换的,需要通过屏幕坐标系来进行转换(因为屏幕坐标是固定的),即先将游戏场景中的世界坐标通过游戏场景Camera转化为 ...

  8. python tkinter模块 创建窗口V1.2

    先上图 代码如下 #-*-coding:utf-8-*- import os from tkinter import * root=Tk() root.title('执行窗口') "&quo ...

  9. Charles 下载-破解-安装-配置

    我当前使用版本为V4.2.7 最新版本下载地址 Charles 在线破解工具 下载完之后,先进行安装,安装完之后,根据破解链接中的步骤来就ok了. 比较费劲配置在下面,不过跟着一步步来就一定能好的 点 ...

  10. 洋葱浏览器(Tor Browser)

    第一,洋葱路由器简介 Tor Browser 是個內建「翻牆」功能的網路瀏覽器,藉由「洋蔥路由, The Onion Router (Tor)」匿名瀏覽技術,將上網時所傳遞的訊息層層加密保護,讓使用者 ...