首页 技术 正文
技术 2022年11月15日
0 收藏 485 点赞 2,311 浏览 617 个字

n<=400个东西,每个东西有高度<=100,这种东西在堆放过程中不得超过的最大高度<=40000,以及每个东西的个数<=10,求最高能堆多高。

算了下背包复杂度不太对然后开了bitset。。

 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
//#include<iostream>
using namespace std; int n;
#define maxn 411
struct Obj{int h,m,c;}a[maxn];
bool cmp(const Obj &a,const Obj &b) {return a.m<b.m;}
bitset<> f,tmp,t;
int main()
{
scanf("%d",&n);
for (int i=;i<=n;i++) scanf("%d%d%d",&a[i].h,&a[i].m,&a[i].c);
f.reset();f[]=;
tmp.set();
sort(a+,a++n,cmp);
for (int i=;i<=n;i++)
{
for (int j=;j<=a[i].c;j++)
f|=(f<<a[i].h);
t=tmp<<(a[i].m+);t.flip();
f&=t;
}
int ans;
for (ans=;ans;ans--) if (f[ans]) break;
printf("%d\n",ans);
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,087
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,562
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,821
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905